:root {
  --bg: #f3f6f8;
  --panel: #ffffff;
  --line: #dce4ea;
  --text: #1d2730;
  --muted: #687785;
  --blue: #246b8f;
  --teal: #1f9a8a;
  --gold: #b6842d;
  --red: #b9443f;
  --green: #287d52;
  --shadow: 0 18px 45px rgba(29, 39, 48, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
  background: #184d68;
}

.login-card {
  display: grid;
  gap: 14px;
  width: min(100%, 390px);
  padding: 28px;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 8px;
  letter-spacing: 0;
}

.login-card .eyebrow {
  color: var(--blue);
}

.login-card button {
  min-height: 42px;
  color: white;
  background: var(--blue);
  border: 0;
  border-radius: 6px;
  font-weight: 700;
}

.login-error {
  margin: 0;
  padding: 10px 12px;
  color: var(--red);
  background: #fff0ef;
  border: 1px solid #f0c6c4;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px;
  color: white;
  background: #184d68;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-action,
.ghost-action,
.secondary-action,
.danger-action {
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 6px;
  font-weight: 700;
}

.primary-action {
  color: #184d68;
  background: #ffffff;
  border: 0;
}

.ghost-action {
  color: var(--blue);
  background: white;
  border: 1px solid var(--line);
}

.danger-action {
  color: #b42318;
  background: #fff5f5;
  border: 1px solid #f4b8b0;
}

.secondary-action {
  color: white;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.profile-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-header h1,
.section-title h2,
.profile-head h2 {
  margin: 0;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  opacity: 0.72;
}

.user-pill,
.count-pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.user-pill {
  background: rgba(255, 255, 255, 0.14);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(430px, 0.95fr) minmax(520px, 1.35fr);
  gap: 20px;
  padding: 22px;
}

.search-panel,
.profile-panel {
  min-height: calc(100vh - 116px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.capture-panel {
  margin: 18px 22px 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.capture-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.capture-head h2 {
  margin: 0;
}

.capture-head .eyebrow {
  color: var(--teal);
}

.section-title,
.profile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.section-title .eyebrow,
.profile-head .eyebrow {
  color: var(--blue);
}

.count-pill {
  color: var(--blue);
  background: #e6f2f6;
}

.search-box {
  display: grid;
  gap: 8px;
  padding: 18px 20px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-box input {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

.search-box input:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 107, 143, 0.16);
}

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 16px;
}

.due-panel {
  margin: 0 20px 18px;
  padding: 14px;
  background: #f7fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.due-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.due-head h3 {
  margin: 0;
}

.due-head label {
  width: 118px;
}

.due-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.due-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  width: 100%;
  padding: 10px;
  color: var(--text);
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: left;
}

.due-item strong,
.due-item span {
  display: block;
}

.due-item small {
  color: var(--muted);
  font-weight: 700;
}

.due-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.filter-button,
.tab-button {
  min-height: 34px;
  padding: 7px 12px;
  color: var(--blue);
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 700;
}

.filter-button.is-active,
.tab-button.is-active {
  color: white;
  background: var(--blue);
  border-color: var(--blue);
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  color: var(--muted);
  background: #f7fafb;
  text-align: left;
  font-weight: 700;
}

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

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover,
tbody tr.is-selected {
  background: #eaf4f7;
}

.client-row {
  cursor: pointer;
}

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

.empty-state {
  display: grid;
  place-content: center;
  min-height: calc(100vh - 116px);
  padding: 32px;
  text-align: center;
}

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

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

.hidden {
  display: none !important;
}

.status-badge {
  color: white;
  background: var(--blue);
}

.status-badge.atrasado {
  background: var(--red);
}

.status-badge.liquidado {
  background: var(--green);
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.tab-panel {
  padding: 20px;
}

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

.info-item,
.summary-grid > div {
  min-height: 70px;
  padding: 13px;
  background: #f7fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.info-item span,
.summary-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.info-item strong,
.summary-grid strong {
  font-size: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.payment-form,
.history-form,
.client-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px;
  background: #eef6f4;
  border: 1px solid #cbe1dd;
  border-radius: 8px;
}

.payment-form h3,
.history-form h3,
.client-form h3 {
  grid-column: 1 / -1;
  margin: 0 0 4px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  padding: 9px 10px;
  color: var(--text);
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

textarea {
  resize: vertical;
}

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

.payment-form button,
.history-form button,
.client-form button {
  align-self: end;
  min-height: 39px;
  padding: 9px 14px;
  color: white;
  background: var(--teal);
  border: 0;
  border-radius: 6px;
  font-weight: 700;
}

.client-form {
  margin: 0;
  padding: 18px 20px 20px;
  background: #f7fafb;
  border: 0;
  border-radius: 0;
}

.client-form h3 {
  padding-top: 8px;
  color: var(--blue);
  border-top: 1px solid var(--line);
}

.client-form h3:first-child {
  padding-top: 0;
  border-top: 0;
}

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

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.history-form {
  grid-template-columns: 180px 1fr 150px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.history-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.history-item strong {
  color: var(--blue);
}

.history-item p {
  margin: 0;
  color: var(--text);
}

.mini-status {
  display: inline-flex;
  min-width: 86px;
  justify-content: center;
  padding: 5px 8px;
  border-radius: 999px;
  color: white;
  font-size: 12px;
  font-weight: 700;
}

.mini-status.pagado {
  background: var(--green);
}

.mini-status.parcial {
  background: var(--gold);
}

.mini-status.pendiente {
  background: var(--muted);
}

.mini-status.vencido {
  background: var(--red);
}

@media (max-width: 1020px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .search-panel,
  .profile-panel,
  .empty-state {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .app-header,
  .section-title,
  .profile-head,
  .capture-head,
  .profile-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .app-shell {
    padding: 12px;
  }

  .due-head {
    align-items: stretch;
    flex-direction: column;
  }

  .due-head label {
    width: 100%;
  }

  .info-grid,
  .summary-grid,
  .payment-form,
  .history-form,
  .client-form {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
  }
}
