:root {
  --apd2-navy: #081b35;
  --apd2-blue: #155bd7;
  --apd2-cyan: #23c8e7;
  --apd2-green: #047857;
  --apd2-red: #b42318;
  --apd2-amber: #9a6700;
}

.apd2-email-field {
  direction: ltr;
  font-variant-ligatures: none;
}

.apd2-email-wrap {
  min-width: 0;
  max-width: 28rem;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.apd2-tools-button {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 2147483000;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  min-height: 3rem;
  padding: .7rem 1rem;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  background: var(--apd2-navy);
  color: #fff;
  box-shadow: 0 16px 40px rgba(8,27,53,.28);
  font: 700 .92rem/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
}

.apd2-tools-button:hover,
.apd2-tools-button:focus-visible {
  background: #10345f;
  outline: 3px solid rgba(35,200,231,.32);
  outline-offset: 2px;
}

.apd2-tools-button span:first-child {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--apd2-cyan);
  color: var(--apd2-navy);
  font-size: 1rem;
}

.apd2-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483100;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(2, 10, 25, .67);
  backdrop-filter: blur(5px);
}

.apd2-overlay[hidden],
.apd2-tools-button[hidden] {
  display: none !important;
}

.apd2-modal {
  width: min(72rem, 100%);
  max-height: calc(100dvh - 2rem);
  overflow: hidden;
  border: 1px solid #d8e0eb;
  border-radius: 1.25rem;
  background: #f5f7fb;
  color: #101828;
  box-shadow: 0 28px 90px rgba(0,0,0,.34);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.apd2-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--apd2-navy);
  color: #fff;
}

.apd2-modal-title {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-width: 0;
}

.apd2-modal-title-badge {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: .8rem;
  background: linear-gradient(135deg, #1ad0eb, #58e0c2);
  color: var(--apd2-navy);
  font-weight: 900;
}

.apd2-modal-title h2 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.2;
}

.apd2-modal-title p {
  margin: .2rem 0 0;
  color: #b9c7da;
  font-size: .78rem;
}

.apd2-icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: .7rem;
  background: rgba(255,255,255,.08);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
}

.apd2-tabs {
  display: flex;
  gap: .35rem;
  padding: .75rem 1rem 0;
  overflow-x: auto;
  background: #fff;
  border-bottom: 1px solid #dce3ed;
}

.apd2-tab {
  flex: 0 0 auto;
  padding: .7rem .95rem;
  border: 0;
  border-radius: .65rem .65rem 0 0;
  background: transparent;
  color: #526071;
  font-weight: 700;
  cursor: pointer;
}

.apd2-tab[aria-selected="true"] {
  background: #eaf2ff;
  color: #124ba7;
}

.apd2-body {
  max-height: calc(100dvh - 10rem);
  overflow: auto;
  padding: 1rem;
}

.apd2-panel[hidden] { display: none; }

.apd2-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: .9rem;
}

.apd2-toolbar h3 {
  margin: 0;
  font-size: 1rem;
}

.apd2-toolbar p {
  margin: .2rem 0 0;
  color: #667085;
  font-size: .82rem;
}

.apd2-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.apd2-button {
  min-height: 2.45rem;
  padding: .55rem .85rem;
  border: 1px solid #cbd5e1;
  border-radius: .65rem;
  background: #fff;
  color: #1d2939;
  font-weight: 700;
  cursor: pointer;
}

.apd2-button:hover { background: #f0f4fa; }
.apd2-button:disabled { opacity: .52; cursor: not-allowed; }
.apd2-button-primary { border-color: var(--apd2-blue); background: var(--apd2-blue); color: #fff; }
.apd2-button-primary:hover { background: #104bb6; }
.apd2-button-danger { border-color: #f3b5ae; color: var(--apd2-red); background: #fff6f4; }
.apd2-button-success { border-color: #9bd8c1; color: var(--apd2-green); background: #effcf6; }
.apd2-button-warning { border-color: #ebcf87; color: var(--apd2-amber); background: #fffaeb; }

.apd2-card {
  margin-bottom: .8rem;
  padding: 1rem;
  border: 1px solid #dce3ed;
  border-radius: .9rem;
  background: #fff;
  box-shadow: 0 3px 12px rgba(15,35,60,.04);
}

.apd2-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .8rem;
}

.apd2-field {
  display: grid;
  gap: .35rem;
  min-width: 0;
}

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

.apd2-field label {
  font-size: .79rem;
  font-weight: 750;
  color: #344054;
}

.apd2-input,
.apd2-select {
  width: 100%;
  min-width: 0;
  min-height: 2.65rem;
  padding: .6rem .7rem;
  border: 1px solid #cbd5e1;
  border-radius: .65rem;
  background: #fff;
  color: #101828;
  font: inherit;
}

.apd2-input:focus,
.apd2-select:focus {
  border-color: #4b83e3;
  outline: 3px solid rgba(21,91,215,.14);
}

.apd2-table-wrap {
  overflow-x: auto;
  border: 1px solid #dce3ed;
  border-radius: .9rem;
  background: #fff;
}

.apd2-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .86rem;
}

.apd2-table th,
.apd2-table td {
  padding: .75rem;
  border-bottom: 1px solid #e8edf4;
  text-align: left;
  vertical-align: top;
}

.apd2-table th {
  color: #475467;
  background: #f8fafc;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .035em;
}

.apd2-table tr:last-child td { border-bottom: 0; }
.apd2-table strong { color: #101828; }

.apd2-muted { color: #667085; }
.apd2-small { font-size: .76rem; }

.apd2-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .23rem .48rem;
  border-radius: 999px;
  background: #eef2f7;
  color: #475467;
  font-size: .7rem;
  font-weight: 800;
}

.apd2-badge-green { background: #e8f7f0; color: #067647; }
.apd2-badge-red { background: #fff0ee; color: #b42318; }
.apd2-badge-blue { background: #eaf2ff; color: #175cd3; }
.apd2-badge-amber { background: #fff7dd; color: #8a6100; }

.apd2-empty,
.apd2-loading {
  padding: 2rem 1rem;
  text-align: center;
  color: #667085;
}

.apd2-session {
  margin-bottom: .8rem;
  overflow: hidden;
  border: 1px solid #dce3ed;
  border-radius: .9rem;
  background: #fff;
}

.apd2-session-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .65rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid #e8edf4;
  background: #f8fafc;
}

.apd2-session-head h4 { margin: 0; font-size: .94rem; }
.apd2-session-head p { margin: .25rem 0 0; color: #667085; font-size: .78rem; }

.apd2-record {
  display: grid;
  grid-template-columns: minmax(7rem, .8fr) minmax(12rem, 1.5fr) auto;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid #edf1f6;
}

.apd2-record:last-child { border-bottom: 0; }
.apd2-record-title { font-weight: 800; }

.apd2-notice {
  margin-bottom: .9rem;
  padding: .75rem .85rem;
  border: 1px solid #bcd2f4;
  border-radius: .75rem;
  background: #eff6ff;
  color: #174b91;
  font-size: .82rem;
  line-height: 1.45;
}

.apd2-notice-error { border-color: #f1b8b0; background: #fff3f1; color: #9f281e; }
.apd2-notice-success { border-color: #9ddbc5; background: #effcf6; color: #05603a; }

.apd2-toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  z-index: 2147483600;
  max-width: min(34rem, calc(100% - 2rem));
  transform: translateX(-50%);
  padding: .8rem 1rem;
  border-radius: .8rem;
  background: #101828;
  color: #fff;
  box-shadow: 0 14px 40px rgba(0,0,0,.25);
  font: 700 .86rem/1.4 system-ui, sans-serif;
}

.apd2-password-card {
  width: min(29rem, 100%);
  padding: 1.25rem;
  border-radius: 1rem;
  background: #fff;
  box-shadow: 0 22px 70px rgba(0,0,0,.3);
  font-family: system-ui, sans-serif;
}

.apd2-password-card h2 { margin: 0; color: #101828; }
.apd2-password-card p { color: #667085; line-height: 1.5; }

.apd2-recovery-link {
  display: block;
  width: 100%;
  margin-top: .65rem;
  border: 0;
  background: transparent;
  color: #175cd3;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 760px) {
  .apd2-overlay { padding: 0; }
  .apd2-modal { width: 100%; max-height: 100dvh; min-height: 100dvh; border-radius: 0; }
  .apd2-body { max-height: calc(100dvh - 9rem); }
  .apd2-form { grid-template-columns: 1fr; }
  .apd2-field-wide { grid-column: auto; }
  .apd2-record { grid-template-columns: 1fr; }
  .apd2-record .apd2-actions { justify-content: flex-start; }
  .apd2-tools-button { right: .75rem; bottom: .75rem; }
  .apd2-tools-button span:last-child { display: none; }
}

@media print {
  .apd2-tools-button,
  .apd2-overlay { display: none !important; }
}

/* APD Presencia 3.0 */
.apd3-inline-tools {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.3rem;
  margin-left: .55rem;
  padding: .45rem .8rem;
  border: 1px solid #0b1f3a;
  border-radius: .75rem;
  background: #0b1f3a;
  color: #fff;
  font: 750 .84rem/1 system-ui, sans-serif;
  cursor: pointer;
}

.apd3-inline-tools:hover { background: #12345b; }

.apd3-input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .45rem;
}

.apd3-file-drop {
  display: grid;
  place-items: center;
  min-height: 8rem;
  padding: 1rem;
  border: 2px dashed #a9bdd8;
  border-radius: .9rem;
  background: #f6f9fd;
  color: #173a67;
  text-align: center;
  cursor: pointer;
}

.apd3-file-drop span {
  margin-top: .25rem;
  color: #667085;
  font-size: .78rem;
}

.apd3-import-preview { margin-top: .9rem; }

.apd2-notice-warning {
  border-color: #e9cb76;
  background: #fff9e8;
  color: #765400;
}

.apd2-notice span { display: block; margin-top: .2rem; }

.apd3-username-field { text-transform: lowercase; }

@media (max-width: 760px) {
  .apd3-inline-tools { margin-left: .35rem; font-size: 0; }
  .apd3-inline-tools::after { content: "⚙"; font-size: 1rem; }
  .apd3-input-action { grid-template-columns: 1fr; }
}
