:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-soft: #fbfbfd;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --muted-2: #8a8a90;
  --line: rgba(60, 60, 67, 0.15);
  --line-strong: rgba(60, 60, 67, 0.24);
  --accent: #0071e3;
  --accent-soft: #eaf3ff;
  --green: #248a3d;
  --red: #d70015;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 22px 70px rgba(0, 0, 0, 0.09);
  --radius: 8px;
  --radius-lg: 18px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(245, 245, 247, 0.98) 42%, #f0f0f3),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.appShell {
  width: min(1380px, calc(100% - 36px));
  margin: 0 auto;
  padding: 22px 0 48px;
}

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

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

.appMark {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(135deg, #ffffff, #edf4ff),
    var(--surface);
  box-shadow: var(--shadow-sm);
  position: relative;
}

.appMark::before,
.appMark::after {
  content: "";
  position: absolute;
  border-radius: 3px;
  background: var(--accent);
}

.appMark::before {
  left: 12px;
  right: 12px;
  top: 12px;
  height: 3px;
}

.appMark::after {
  left: 12px;
  right: 16px;
  top: 20px;
  height: 3px;
  box-shadow: 0 8px 0 rgba(0, 113, 227, 0.45);
}

.eyebrow,
.panelTitle p,
.resultsHeader p,
.drawerPanel p {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1.05;
  font-weight: 760;
}

.statusPill {
  min-width: 120px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.statusPill.ready {
  color: var(--green);
  background: rgba(36, 138, 61, 0.08);
}

.statusPill.error {
  color: var(--red);
  background: rgba(215, 0, 21, 0.08);
}

.heroPanel,
.searchPanel,
.resultsPanel,
.sidePanel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-sm);
}

.heroPanel {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(330px, 0.82fr);
  gap: 24px;
  align-items: end;
  padding: 28px;
}

.heroCopy h2 {
  max-width: 820px;
  margin-bottom: 10px;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1.04;
  font-weight: 780;
}

.heroCopy p {
  max-width: 690px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.48;
}

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

.metric {
  min-height: 94px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.metric span {
  display: block;
  margin-bottom: 6px;
  font-size: 25px;
  line-height: 1.1;
  font-weight: 760;
  white-space: nowrap;
}

.metric small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.searchPanel {
  margin-top: 16px;
  padding: 18px;
}

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

.panelTitle h3,
.sidePanel h3,
.resultsHeader h3 {
  margin-bottom: 5px;
  font-size: 18px;
  line-height: 1.2;
}

.panelTitle p,
.resultsHeader p {
  margin-bottom: 0;
  font-size: 13px;
}

.searchBox {
  position: relative;
  display: block;
}

.searchBox input {
  width: 100%;
  height: 52px;
  padding: 0 18px 0 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
}

.searchBox input::placeholder {
  color: var(--muted-2);
}

.searchBox input:focus,
select:focus {
  border-color: rgba(0, 113, 227, 0.55);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12);
}

.searchIcon,
.icon,
.chevron,
.closeIcon {
  display: inline-block;
  position: relative;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.searchIcon {
  position: absolute;
  left: 17px;
  top: 17px;
  border: 2px solid #77777d;
  border-radius: 50%;
}

.searchIcon::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 2px;
  right: -6px;
  bottom: -3px;
  background: #77777d;
  transform: rotate(45deg);
  border-radius: 2px;
}

.filterGrid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.filterGrid label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.filterGrid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: var(--surface);
  color: var(--text);
  padding: 0 34px 0 12px;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #68686d 50%),
    linear-gradient(135deg, #68686d 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 18px,
    calc(100% - 12px) 18px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

select option {
  color: var(--text);
  background: #fff;
}

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

.button,
.iconButton {
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 15px;
  border-radius: var(--radius);
  font-weight: 700;
  text-decoration: none;
}

.button:hover,
.iconButton:hover {
  transform: translateY(-1px);
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button.secondary {
  background: var(--surface);
  color: var(--text);
}

.searchButtonIcon::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 9px;
  height: 9px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.searchButtonIcon::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 2px;
  right: 1px;
  bottom: 3px;
  background: currentColor;
  border-radius: 2px;
  transform: rotate(45deg);
}

.cancelIcon::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 3px;
  background: currentColor;
}

.resetIcon::before,
.resetIcon::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 2px;
  top: 8px;
  left: 2px;
  background: currentColor;
  border-radius: 2px;
}

.resetIcon::before {
  transform: rotate(45deg);
}

.resetIcon::after {
  transform: rotate(-45deg);
}

.contentGrid {
  display: grid;
  grid-template-columns: minmax(0, 280px) minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
  min-width: 0;
  overflow: hidden;
}

.sidePanel,
.resultsPanel {
  padding: 16px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.sidePanel {
  position: sticky;
  top: 16px;
  align-self: start;
  width: 100%;
}

.quickList {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.quickItem {
  display: grid;
  grid-template-rows: auto auto;
  gap: 3px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-inline-size: 0;
  inline-size: 100%;
  max-inline-size: 100%;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  contain: layout paint;
}

.quickItem > * {
  min-width: 0;
  max-width: 100%;
}

.quickItem:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.quickItem strong {
  display: block;
  min-width: 0;
  max-width: 100%;
  margin-bottom: 0;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quickItem span {
  display: -webkit-box;
  min-width: 0;
  max-width: 100%;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.resultsHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  min-width: 0;
}

.resultsHeader > div:first-child {
  min-width: 0;
}

.pager {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.iconButton {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
}

.iconButton:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}

.chevron::before {
  content: "";
  position: absolute;
  inset: 4px 5px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
}

.chevron.left::before {
  transform: rotate(-135deg);
}

.chevron.right::before {
  transform: rotate(45deg);
}

.resultsList {
  display: grid;
  gap: 10px;
}

.docCard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.docCard:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.docTitle {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.fileBadge {
  min-width: 42px;
  padding: 5px 7px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: #005bb8;
  text-align: center;
  font-size: 11px;
  font-weight: 780;
  text-transform: uppercase;
}

.docTitle h4 {
  margin: 0;
  font-size: 16px;
  line-height: 1.28;
  min-width: 0;
  overflow-wrap: anywhere;
}

.docMeta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 9px;
}

.tag {
  padding: 5px 8px;
  border-radius: 999px;
  background: #f2f2f7;
  color: #4d4d52;
  font-size: 12px;
  font-weight: 650;
}

.tag.exists {
  background: rgba(36, 138, 61, 0.1);
  color: var(--green);
}

.tag.missing {
  background: rgba(215, 0, 21, 0.1);
  color: var(--red);
}

.docConcept {
  margin: 0;
  color: #343437;
  line-height: 1.45;
  font-size: 14px;
}

.docPath {
  margin-top: 9px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.docActions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 130px;
}

.docActions .button {
  width: 100%;
}

.emptyState {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed rgba(60, 60, 67, 0.26);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.emptyState p {
  margin-bottom: 0;
}

.previewDrawer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 30;
}

.previewDrawer.open {
  pointer-events: auto;
  opacity: 1;
}

.drawerBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.28);
}

.drawerPanel {
  position: absolute;
  right: 0;
  top: 0;
  width: min(880px, 100%);
  height: 100%;
  background: #f8f8fb;
  box-shadow: -18px 0 60px rgba(0, 0, 0, 0.18);
  transform: translateX(24px);
  transition: transform 0.22s ease;
  display: grid;
  grid-template-rows: auto 1fr;
}

.previewDrawer.open .drawerPanel {
  transform: translateX(0);
}

.drawerPanel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
}

.drawerPanel h3 {
  margin-bottom: 0;
  font-size: 18px;
}

.drawerPanel p {
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.closeIcon::before,
.closeIcon::after {
  content: "";
  position: absolute;
  top: 8px;
  left: 3px;
  width: 13px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}

.closeIcon::before {
  transform: rotate(45deg);
}

.closeIcon::after {
  transform: rotate(-45deg);
}

.previewBody {
  min-height: 0;
  padding: 16px;
}

.previewBody iframe,
.previewBody img {
  width: 100%;
  height: 100%;
  min-height: 70vh;
  border: 0;
  border-radius: var(--radius);
  background: #fff;
}

@media (max-width: 980px) {
  .heroPanel,
  .contentGrid {
    grid-template-columns: 1fr;
  }

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

  .sidePanel {
    position: static;
  }
}

@media (max-width: 640px) {
  .appShell {
    width: min(100% - 20px, 1380px);
    padding-top: 14px;
  }

  .topbar,
  .resultsHeader {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar,
  .resultsHeader {
    display: flex;
  }

  .heroPanel,
  .searchPanel,
  .resultsPanel,
  .sidePanel {
    padding: 14px;
    border-radius: 14px;
  }

  .heroCopy h2 {
    font-size: 32px;
  }

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

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

  .docActions {
    min-width: 0;
  }
}

/* Modales y Acciones NAS */
.headerActions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modalBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modalBackdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modalCard {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: min(600px, calc(100vw - 32px));
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  border: 1px solid var(--line);
}

.modalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.modalHeader h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.modalForm {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dropzone {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  background: var(--surface-soft);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

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

.selectedFileName {
  display: block;
  margin-top: 8px;
  font-weight: 600;
  color: var(--accent);
  word-break: break-all;
}

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

.fullWidthLabel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fullWidthLabel span {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.fullWidthLabel textarea {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-soft);
  resize: vertical;
}

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

.button.danger {
  background: #fff0f0;
  color: var(--red);
  border: 1px solid rgba(215, 0, 21, 0.2);
}

.button.danger:hover {
  background: var(--red);
  color: white;
}

