:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #647084;
  --line: #d9e0ea;
  --brand: #004a98;
  --brand-strong: #00356f;
  --brand-soft: #e8f1fb;
  --accent: #d71920;
  --accent-soft: #fff0f1;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(0, 74, 152, .09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

.app {
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(0, 74, 152, .10), rgba(215, 25, 32, .07)),
    var(--bg);
}

.login-panel {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
  padding: 30px;
}

.login-brand {
  margin-bottom: 28px;
  color: var(--ink);
}

.login-copy {
  margin: 14px 0 22px;
  color: var(--muted);
  line-height: 1.5;
}

.login-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.login-domain {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.brand-logo {
  width: 108px;
  height: auto;
  display: block;
  border-radius: 6px;
  background: white;
  padding: 6px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .08);
}

.login-brand .brand-logo {
  width: 132px;
  background: transparent;
  padding: 0;
  box-shadow: none;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #b7cbe2;
  font-size: 13px;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.header-title {
  display: grid;
  gap: 10px;
}

.header-logo {
  width: 128px;
  height: auto;
  display: block;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 4px;
  margin-bottom: 18px;
}

.tab-item {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
}

.tab-item.active {
  background: var(--brand);
  color: white;
}

.user-badge {
  max-width: 340px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  padding: 8px 10px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.user-badge a {
  color: var(--brand-strong);
  font-weight: 800;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: white;
  object-fit: cover;
  flex: 0 0 auto;
}

.user-avatar-fallback {
  display: inline-grid;
  place-items: center;
  background: var(--brand);
  color: white;
  font-size: 15px;
  font-weight: 800;
}

.user-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.user-name,
.user-email {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-name {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.user-email {
  color: var(--muted);
  font-size: 12px;
}

.logout-button {
  min-width: 76px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1, h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

.primary,
.secondary,
.danger {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
}

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

.primary:hover:not(:disabled) {
  background: var(--brand-strong);
}

.secondary {
  background: white;
  color: var(--brand-strong);
  border-color: var(--line);
}

.danger {
  background: var(--accent-soft);
  color: var(--danger);
  border-color: #f1b8b3;
  font-weight: 800;
}

.danger:hover:not(:disabled) {
  background: #fee2e2;
}

.primary:disabled,
.secondary:disabled,
.danger:disabled,
.icon-button:disabled {
  opacity: .6;
  cursor: progress;
}

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

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 28px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 170px 190px 130px auto;
  gap: 10px;
  margin-bottom: 18px;
}

.field {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0 12px;
}

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

.list-panel,
.detail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.list-head {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.list-head span {
  color: var(--muted);
  font-size: 13px;
}

.state {
  padding: 28px 16px;
  color: var(--muted);
}

.cards {
  display: grid;
}

.pagination {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: #fbfcfe;
}

.pagination[hidden] {
  display: none;
}

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

.page-size {
  width: 86px;
  min-height: 38px;
}

.page-buttons {
  display: flex;
  gap: 8px;
}

.page-button {
  min-height: 38px;
  padding: 0 12px;
}

.card {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: white;
  color: var(--ink);
  text-align: left;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  cursor: pointer;
}

.card:hover,
.card.selected {
  background: var(--brand-soft);
}

.card strong,
.meta,
.requester,
.comment {
  min-width: 0;
  overflow-wrap: anywhere;
}

.meta,
.requester,
.comment {
  color: var(--muted);
  font-size: 13px;
}

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

.badge {
  justify-self: end;
  align-self: start;
  border-radius: 999px;
  background: #fff4d8;
  color: #8a5a00;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}

.badge.aprobado {
  background: #dcfce7;
  color: #166534;
}

.badge.rechazado {
  background: #fee2e2;
  color: #991b1b;
}

.badge.pendiente {
  background: #fff4d8;
  color: #8a5a00;
}

.detail {
  position: sticky;
  top: 22px;
  padding: 18px;
}

dl {
  margin: 18px 0 0;
  display: grid;
  gap: 14px;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 3px;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 32, 45, .52);
  z-index: 20;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(720px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(0,0,0,.24);
  padding: 20px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.modal-details {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.comment-label {
  display: block;
  margin: 16px 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.comment-box {
  width: 100%;
  resize: vertical;
  min-height: 100px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
}

.comment-box:read-only {
  background: #f5f7fa;
}

.comment-box:disabled {
  background: #eef2f7;
  color: #2d3848;
  opacity: 1;
}

.decision-message {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.send-decision {
  min-width: 110px;
}

@media (max-width: 980px) {
  .main {
    padding: 18px;
  }

  .content {
    grid-template-columns: 1fr;
  }

  .detail {
    position: static;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .user-badge {
    max-width: none;
  }

  .tabs {
    display: flex;
  }

  .tab-item {
    flex: 1;
  }

  .metrics,
  .toolbar {
    grid-template-columns: 1fr;
  }

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

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

  h1 {
    font-size: 23px;
  }

  .card {
    grid-template-columns: 1fr;
  }

  .badge {
    justify-self: start;
  }

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

  .modal-actions {
    flex-direction: column-reverse;
  }
}
