:root {
  --apl-red: #d5000f;
  --apl-red-dark: #a9000c;
  --graphite: #25272b;
  --muted: #686d76;
  --border: #e5e7eb;
  --background: #f5f6f8;
  --surface: #ffffff;
  --success: #16794d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--graphite);
  font-family: Inter, Arial, Helvetica, sans-serif;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 32px max(24px, calc((100vw - 1180px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-header h1 {
  margin: 4px 0 8px;
  font-size: clamp(26px, 4vw, 40px);
}

.app-header p {
  margin: 0;
  color: var(--muted);
}

.app-kicker,
.section-label {
  color: var(--apl-red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.status-badge {
  padding: 9px 14px;
  border-radius: 999px;
  background: #e5f5ed;
  color: var(--success);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.container {
  width: min(1180px, calc(100% - 32px));
  margin: 32px auto;
}

.welcome-card,
.stat-card,
.error-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 6px 20px rgba(24, 29, 38, 0.05);
}

.welcome-card {
  padding: 28px;
  border-left: 5px solid var(--apl-red);
}

.welcome-card h2 {
  margin: 6px 0 10px;
}

.welcome-card p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.stat-card {
  padding: 22px;
}

.stat-card span,
.stat-card small {
  display: block;
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin: 10px 0;
  font-size: 34px;
}

.error-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.error-card {
  width: min(500px, 100%);
  padding: 36px;
  text-align: center;
}

.error-code {
  color: var(--apl-red);
  font-size: 56px;
  font-weight: 900;
}

.button {
  display: inline-block;
  margin-top: 14px;
  padding: 11px 18px;
  border-radius: 9px;
  background: var(--apl-red);
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
}

.button:hover {
  background: var(--apl-red-dark);
}

@media (max-width: 760px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

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

@media (max-width: 440px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(
      145deg,
      #202226 0%,
      #32353b 55%,
      #d5000f 160%
    );
}

.login-card {
  width: min(430px, 100%);
  padding: 34px;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
}

.login-brand {
  margin-bottom: 26px;
}

.login-brand h1 {
  margin: 5px 0 8px;
  font-size: 32px;
}

.login-brand p {
  margin: 0;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 18px;
}

.login-form label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #cfd3da;
  border-radius: 9px;
  font: inherit;
}

.login-form input:focus {
  border-color: var(--apl-red);
  outline: 3px solid rgba(213, 0, 15, 0.12);
}

.button {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.button-full {
  width: 100%;
}

.alert {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 9px;
}

.alert-error {
  background: #fde8e8;
  color: #9b111e;
}

.header-actions,
.user-area,
.main-nav,
.page-heading,
.panel-heading,
.import-panel,
.import-form,
.form-actions {
  display: flex;
  align-items: center;
}

.header-actions {
  gap: 28px;
}

.main-nav {
  gap: 8px;
}

.main-nav a,
.link-button {
  padding: 9px 11px;
  border: 0;
  background: transparent;
  color: var(--graphite);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.main-nav a:hover,
.link-button:hover {
  color: var(--apl-red);
}

.user-area {
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.page-heading {
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.page-heading h2 {
  margin: 5px 0 8px;
  font-size: 30px;
}

.page-heading p {
  margin: 0;
  color: var(--muted);
}

.panel {
  margin-top: 22px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 6px 20px rgba(24, 29, 38, 0.05);
}

.panel-heading {
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}

.panel-heading h3,
.import-panel h3 {
  margin: 0;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

th {
  background: #f8f9fa;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.table-subtitle {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.table-action {
  text-align: right;
}

.empty-state {
  padding: 46px 24px;
  text-align: center;
}

.empty-state h3 {
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0 0 18px;
  color: var(--muted);
}

.container-narrow {
  max-width: 820px;
}

.form-panel {
  padding: 26px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-grid label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

.form-grid input {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #cfd3da;
  border-radius: 9px;
  font: inherit;
}

.form-grid input:focus {
  border-color: var(--apl-red);
  outline: 3px solid rgba(213, 0, 15, 0.12);
}

.input-suffix {
  display: flex;
  align-items: center;
  gap: 10px;
}

.input-suffix span {
  color: var(--muted);
  font-weight: 400;
}

.form-actions {
  grid-column: 1 / -1;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 8px;
}

.import-panel {
  justify-content: space-between;
  gap: 24px;
  padding: 22px;
}

.import-panel p {
  margin: 7px 0 0;
  color: var(--muted);
}

.import-form {
  gap: 12px;
}

.button-secondary {
  background: #eceef1;
  color: var(--graphite);
}

.button-secondary:hover {
  background: #dadde2;
}

.button-small {
  margin: 0;
  padding: 8px 12px;
  font-size: 13px;
}

.alert-success {
  background: #e3f4eb;
  color: #176b3a;
}

.alert-warning {
  background: #fff2cc;
  color: #7a5700;
}

.status {
  display: inline-flex;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status-pendente {
  background: #fff2cc;
  color: #7a5700;
}

@media (max-width: 900px) {
  .app-header,
  .header-actions,
  .page-heading,
  .import-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    gap: 12px;
  }
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .import-form {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .import-form input,
  .import-form button {
    width: 100%;
  }
}

.public-confirmation-page {
  min-height: 100vh;
  padding: 24px;
  background:
    linear-gradient(
      145deg,
      #202226 0%,
      #32353b 58%,
      #8f000a 150%
    );
}

.public-confirmation-card {
  width: min(620px, 100%);
  margin: 40px auto;
  padding: 32px;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
}

.public-brand {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.public-brand h1 {
  margin: 6px 0 8px;
}

.public-brand p {
  margin: 0;
  color: var(--muted);
}

.public-lot-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 24px 0;
  overflow: hidden;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.public-lot-details > div {
  display: grid;
  gap: 6px;
  padding: 16px;
  background: #ffffff;
}

.public-lot-details span {
  color: var(--muted);
  font-size: 13px;
}

.public-lot-details strong {
  font-size: 17px;
}

.public-lot-details .public-total {
  grid-column: 1 / -1;
  background: #f8f9fa;
}

.public-total strong {
  color: var(--apl-red);
  font-size: 23px;
}

.public-actions p {
  font-weight: 700;
}

.public-actions form {
  display: grid;
  gap: 12px;
}

.public-button {
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-radius: 10px;
  color: #ffffff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.public-button-confirm {
  background: #16794d;
}

.public-button-support {
  background: #5e626b;
}

.public-button-deny {
  background: var(--apl-red);
}

.public-result {
  margin: 22px 0;
  padding: 16px;
  border-radius: 10px;
}

.public-result p {
  margin: 6px 0 0;
}

.public-result-success {
  background: #e3f4eb;
  color: #176b3a;
}

.public-result-error {
  background: #fde8e8;
  color: #9b111e;
}

.public-footer-message {
  margin-bottom: 0;
  color: var(--muted);
  text-align: center;
}

.public-error-card {
  text-align: center;
}

@media (max-width: 540px) {
  .public-confirmation-page {
    padding: 12px;
  }

  .public-confirmation-card {
    margin: 12px auto;
    padding: 22px;
  }

  .public-lot-details {
    grid-template-columns: 1fr;
  }

  .public-lot-details .public-total {
    grid-column: auto;
  }
}

/* SPRINT 1.2 - PAINEL OPERACIONAL */

.operational-stats {
  grid-template-columns: repeat(6, minmax(150px, 1fr));
}

.import-disclosure {
  padding: 0;
  overflow: hidden;
}

.import-disclosure > summary {
  padding: 20px 24px;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.import-disclosure > summary::-webkit-details-marker {
  display: none;
}

.import-disclosure > summary::after {
  content: "+";
  float: right;
  color: var(--apl-red);
  font-size: 22px;
}

.import-disclosure[open] > summary::after {
  content: "−";
}

.import-disclosure-content {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 0 24px 24px;
  border-top: 1px solid var(--border);
}

.operational-heading {
  align-items: flex-start;
}

.lot-filter-form {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) minmax(200px, 1fr) auto;
  gap: 16px;
  align-items: end;
  padding: 18px 0 22px;
}

.lot-filter-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.lot-filter-form input,
.lot-filter-form select,
.reoffer-form input {
  width: 100%;
  min-height: 43px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #ffffff;
  color: inherit;
  font: inherit;
}

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

.operational-table-wrap {
  overflow: visible;
  overflow-x: auto;
}

.operational-table {
  min-width: 1180px;
}

.operational-table th:last-child,
.operational-table td:last-child {
  min-width: 190px;
}

.bidder-name {
  display: block;
  max-width: 270px;
}

.lot-actions {
  display: grid;
  gap: 7px;
}

.lot-actions form {
  margin: 0;
}

.button-small {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.2;
  text-align: center;
}

.button-whatsapp {
  background: #16794d;
}

.button-whatsapp:hover {
  background: #10663f;
}

.button-danger {
  background: var(--apl-red);
  color: #ffffff;
}

.button-danger:hover {
  filter: brightness(0.9);
}

.reoffer-details {
  position: relative;
}

.reoffer-details > summary {
  display: block;
  list-style: none;
  cursor: pointer;
}

.reoffer-details > summary::-webkit-details-marker {
  display: none;
}

.reoffer-form {
  display: grid;
  gap: 10px;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

.reoffer-form label {
  display: grid;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
}

.status-mensagem-enviada {
  background: #e8f1ff;
  color: #235da7;
}

.status-confirmado {
  background: #e3f4eb;
  color: #176b3a;
}

.status-atendimento {
  background: #fff3d8;
  color: #8a5b00;
}

.status-nao-reconhece {
  background: #fde8e8;
  color: #9b111e;
}

.status-reofertar {
  background: #eceef1;
  color: #4d5159;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 22px;
}

.pagination-info {
  color: var(--muted);
  font-size: 14px;
}

.disabled {
  pointer-events: none;
  opacity: 0.45;
}

@media (max-width: 1280px) {
  .operational-stats {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 760px) {
  .operational-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .import-disclosure-content {
    display: grid;
  }

  .lot-filter-form {
    grid-template-columns: 1fr;
  }

  .filter-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .pagination {
    gap: 9px;
  }
}

/* SPRINT 1.3 - IMPORTAÇÃO INCREMENTAL */

.import-options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding: 1.25rem;
}

.import-option-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.25rem;
  border: 1px solid var(--border-color, #dedede);
  border-radius: 14px;
  background: #fff;
}

.import-option-card h3 {
  margin: 0.35rem 0 0.5rem;
}

.import-option-card p {
  margin: 0;
  line-height: 1.55;
}

.status-aguardando-resultado {
  background: #eceff1;
  color: #37474f;
}

.status-dados-pendentes {
  background: #fff3cd;
  color: #664d03;
}

.action-note {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  background: #eceff1;
  color: #37474f;
  font-size: 0.82rem;
  font-weight: 700;
}

.action-note-warning {
  background: #fff3cd;
  color: #664d03;
}

.table-warning {
  display: block;
  margin-top: 0.25rem;
  color: #b42318;
  font-size: 0.75rem;
  font-weight: 700;
}

@media (max-width: 800px) {
  .import-options-grid {
    grid-template-columns: 1fr;
  }
}

/* IDENTIDADE VISUAL APL */

.brand-logo {
  display: block;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.brand-logo-header {
  height: 46px;
  max-width: 180px;
}

.brand-logo-login {
  height: 72px;
  max-width: 230px;
  margin: 0 auto 1rem;
}

.brand-logo-public {
  height: 64px;
  max-width: 220px;
  margin: 0 auto 1rem;
}

.error-brand {
  display: flex;
  justify-content: center;
  width: 100%;
  margin: 2rem auto 1rem;
}

.brand-logo-error {
  height: 64px;
  max-width: 220px;
}

@media (max-width: 640px) {
  .brand-logo-header {
    height: 38px;
    max-width: 145px;
  }

  .brand-logo-login,
  .brand-logo-public,
  .brand-logo-error {
    height: 54px;
    max-width: 190px;
  }
}
