/* PLI FLUX canonical design layer.
   Loaded after admin.css to apply the Design System without rewriting behavior. */

:root {
  color-scheme: light;

  --pli-primary: #004B97;
  --pli-secondary: #3165AF;
  --pli-accent: #739DD3;
  --pli-text: #333333;
  --pli-white: #FFFFFF;
  --pli-bg: #F6F9FD;
  --pli-bg-soft: #EDF4FB;
  --pli-line: #CAD9EA;
  --pli-line-strong: #A9C0DC;
  --pli-hover: #E8F1FB;
  --pli-hero: #004F9F;
  --pli-signal: #3DDC97;

  --bg: var(--pli-bg);
  --ink: var(--pli-text);
  --muted: var(--pli-secondary);
  --line: var(--pli-line);
  --panel: var(--pli-white);
  --accent: var(--pli-primary);
  --accent-2: var(--pli-secondary);
  --danger: #B42318;
  --soft: var(--pli-bg-soft);

  --status-active-bg: #DCFCE7;
  --status-active-fg: #166534;
  --status-inactive-bg: #FEE2E2;
  --status-inactive-fg: #991B1B;
  --status-neutral-bg: #E7F4F1;
  --status-neutral-fg: #006B5F;
  --status-pending-bg: #EEF4FB;
  --status-pending-fg: #3165AF;
  --status-warning-bg: #FFF7DC;
  --status-warning-fg: #8A5A00;

  --shadow-card: 0 12px 32px rgba(31, 41, 51, .08);
  --shadow-soft: 0 10px 30px rgba(31, 41, 51, .06);
  --shadow-drawer: -18px 0 50px rgba(31, 41, 51, .14);

  --radius-sm: 5px;
  --radius: 7px;
  --radius-md: 8px;
  --radius-pill: 999px;
  --sidebar-w: 260px;

  --font-display: "Avenir Next LT Pro", "Mulish", "Segoe UI", system-ui, sans-serif;
  --font-body: "Avenir Next LT Pro Light", "Avenir Next LT Pro", "Mulish", "Segoe UI", system-ui, sans-serif;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-weight: 300;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0;
}

h1,
h2,
h3,
strong,
label,
button,
.button-link,
.badge,
.status-pill,
.eyebrow,
.nav {
  font-family: var(--font-display);
  letter-spacing: 0;
}

h1,
h2,
h3 {
  color: var(--pli-primary);
}

h1 {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.12;
}

h2 {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.25;
}

h3 {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.3;
}

p,
small,
.muted {
  line-height: 1.55;
}

.muted,
small.muted {
  color: var(--muted);
}

.eyebrow {
  color: var(--pli-primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

/* App shell */
.shell,
.role-layout .project-shell {
  width: calc(100% - var(--sidebar-w));
  max-width: none;
  min-height: 100vh;
  margin-left: var(--sidebar-w);
  /* Más aire horizontal: el contenido ya no queda pegado a los bordes. */
  padding: 28px 40px;
}

.standalone-page .project-shell {
  width: min(100%, 1560px);
  max-width: 1560px;
  margin: 0 auto;
  padding: 28px 40px;
}

.sidebar {
  width: var(--sidebar-w);
  padding: 24px 18px;
  gap: 24px;
  background: var(--pli-primary);
  color: var(--pli-white);
  border-right: 1px solid rgba(255, 255, 255, .22);
}

.brand {
  align-items: center;
  gap: 12px;
}

.brand strong {
  color: var(--pli-white);
  font-size: 16px;
  font-weight: 800;
}

.brand small,
.session small {
  color: rgba(255, 255, 255, .78);
}

.mark {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: var(--radius-md);
  color: var(--pli-primary);
  background: var(--pli-white);
}

.mark img {
  width: 78%;
  height: 78%;
  object-fit: contain;
}

.sidebar nav {
  display: grid;
  gap: 2px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 11px 13px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: rgba(255, 255, 255, .82);
  background: transparent;
  font-size: 13.5px;
  font-weight: 800;
  text-align: left;
}

.nav:hover {
  color: var(--pli-white);
  background: rgba(255, 255, 255, .07);
}

.nav.active {
  color: var(--pli-white);
  background: rgba(255, 255, 255, .1);
  border-left-color: var(--pli-accent);
}

.nav-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 18px;
}

.nav-icon svg,
.project-tab-icon svg,
.icon-button svg,
.return-button svg,
.back-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.panel-icon {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-right: 8px;
  vertical-align: -4px;
  color: var(--pli-blue, #1b4fd1);
}

.panel-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── DocumentPreviewModal ─────────────────────────────────────── */
.docpreview-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 18, 40, .55);
}
.docpreview-overlay.hidden { display: none; }
.docpreview-modal {
  display: flex;
  flex-direction: column;
  width: min(1100px, 96vw);
  height: min(90vh, 100%);
  background: var(--pli-white, #fff);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(8, 18, 40, .35);
}
.docpreview-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(8, 18, 40, .1);
  background: var(--pli-surface, #f4f7fc);
}
.docpreview-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.docpreview-tools { display: flex; align-items: center; gap: 6px; }
.docpreview-zoom { min-width: 46px; text-align: center; font-variant-numeric: tabular-nums; }
.docpreview-actions { display: flex; align-items: center; gap: 8px; }
.docpreview-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: #525a6b;
}
.docpreview-status {
  padding: 32px;
  text-align: center;
  color: var(--pli-white, #fff);
}
.docpreview-status.is-error { color: #ffb4b4; }
.docpreview-pdf-scroll {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px;
}
.docpreview-pdf-page {
  max-width: 100%;
  height: auto;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
  background: #fff;
}
.docpreview-xlsx-scroll {
  overflow: auto;
  height: 100%;
  background: #fff;
  padding: 8px;
}
.docpreview-xlsx-scroll table { border-collapse: collapse; font-size: 13px; }
.docpreview-xlsx-scroll td, .docpreview-xlsx-scroll th {
  border: 1px solid #d4dae6;
  padding: 4px 8px;
  white-space: nowrap;
}
.docpreview-sheet-label { display: inline-flex; align-items: center; gap: 6px; }

.ghost {
  color: var(--pli-white);
  background: rgba(255, 255, 255, .12);
  border: 0;
  border-radius: var(--radius-md);
}

.ghost:hover {
  background: rgba(255, 255, 255, .18);
}

.topbar,
.project-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.project-header {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.actions,
.top-actions,
.panel-heading-actions,
.drawer-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

button,
.button-link {
  font-weight: 800;
  cursor: pointer;
}

main button:not(.nav):not(.project-tab-button):not(.as-row):not(.sheet-row):not(.project-card):not(.chat-react-pick):not(.chat-reaction):not(.chat-abtn):not(.chat-reply-cancel):not(.chat-conversation):not(.announcement-card),
.preview-drawer button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 9px 13px;
  border: 0;
  border-radius: var(--radius-md);
  color: var(--pli-white);
  background: var(--pli-primary);
  font-size: 13px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

button.secondary,
.secondary,
.button-link.secondary {
  color: var(--pli-white);
  background: var(--pli-secondary);
}

button.danger,
.danger {
  color: var(--pli-white);
  background: var(--danger);
}

.button-link {
  background: var(--pli-bg-soft);
  border: 1px solid var(--pli-line);
  color: var(--pli-primary);
}

button:hover,
.button-link:hover {
  filter: brightness(.98);
}

.icon-button,
.notification-button {
  width: 42px;
  height: 42px;
  min-width: 42px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--pli-secondary);
}

.notification-count,
.icon-button .dot {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  padding: 0 4px;
  border: 2px solid var(--bg);
  border-radius: var(--radius-pill);
  color: var(--pli-white);
  background: #D92D20;
  font-size: 10px;
  font-weight: 900;
}

/* Cards and panels */
.panel {
  background: var(--pli-white);
  border: 1px solid var(--pli-line);
  border-radius: var(--radius-md);
  box-shadow: none;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metrics article {
  background: var(--pli-white);
  border: 1px solid var(--pli-line);
  border-radius: var(--radius-md);
  box-shadow: none;
}

.metrics span {
  color: var(--pli-primary);
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 850;
  line-height: 1;
}

.metrics small {
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
}

.project-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--pli-line);
  border-radius: var(--radius-md);
  color: var(--pli-text);
  background: var(--pli-white);
  box-shadow: var(--shadow-card);
  text-align: left;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}

.project-card:hover {
  border-color: #93B7D5;
  background: #FBFDFF;
  transform: translateY(-1px);
}

.project-card-phase,
.project-card-metrics span {
  border-radius: var(--radius);
}

.project-card-topline,
.project-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.project-card-topline small,
.project-card-footer small,
.project-card > small {
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
}

.project-card > strong {
  min-height: 46px;
  color: var(--pli-text);
  font-family: var(--font-display);
  font-size: 19px;
  line-height: 1.22;
}

.project-card-phase {
  display: inline-flex;
  width: fit-content;
  padding: 8px 10px;
  border: 1px solid #D0DCE3;
  color: #344054;
  background: #F8FAFC;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
}

.project-card-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.project-card-metrics span {
  display: grid;
  gap: 2px;
  align-content: center;
  min-height: 62px;
  padding: 10px;
  border: 1px solid #D9E6DF;
  color: var(--pli-text);
  background: #EEF7F4;
}

.project-card-metrics b {
  color: var(--pli-primary);
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1;
}

.project-card-metrics small {
  color: #475467;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

/* Forms */
label,
.field,
.user-code-field,
.project-work-field {
  color: #344054;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  border: 1px solid var(--pli-line);
  border-radius: var(--radius);
  background: var(--pli-white);
  color: var(--ink);
  font-family: var(--font-body);
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(49, 101, 175, .18);
  border-color: var(--pli-secondary);
}

.toolbar input,
.toolbar select,
.project-file-controls input,
.project-file-controls select {
  min-height: 40px;
}

/* Status */
.badge,
.status-pill,
.area-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.1;
}

.badge {
  padding: 4px 9px;
  color: var(--pli-primary);
  background: var(--pli-bg-soft);
}

.status-active {
  color: var(--status-active-fg);
  background: var(--status-active-bg);
}

.status-inactive {
  color: var(--status-inactive-fg);
  background: var(--status-inactive-bg);
}

.status-neutral {
  color: var(--status-neutral-fg);
  background: var(--status-neutral-bg);
}

.status-pending {
  color: var(--status-pending-fg);
  background: var(--status-pending-bg);
}

.status-warning {
  color: var(--status-warning-fg);
  background: var(--status-warning-bg);
}

/* Tables */
.matrix-scroll,
.sheet-scroll,
.panel {
  scrollbar-color: var(--pli-line-strong) var(--pli-bg-soft);
}

.table {
  display: grid;
  gap: 6px;
}

.sheet-row {
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #E8E2D7;
  border-radius: 6px;
  background: var(--pli-white);
}

.sheet-row > *,
.matrix-table .sheet-row > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

.sheet-head,
.matrix-table .sheet-head {
  min-height: 36px;
  border: 0;
  color: #475467;
  background: #F2F4F7;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.sheet-head > *,
.matrix-table .sheet-head > * {
  color: #475467 !important;
}

.matrix-table .sheet-head .table-actions-cell,
.matrix-table .sheet-head .table-actions-head,
.matrix-table .table-actions-head {
  color: #475467 !important;
  background: #F2F4F7 !important;
}

.matrix-table .sheet-row:not(.sheet-head):nth-child(odd) {
  background: #FBFCFE;
}

.matrix-table .sheet-row:not(.sheet-head):nth-child(even) {
  background: #FFFAF1;
}

.sheet-row.clickable:hover,
.matrix-table .sheet-row[data-project-row-link]:hover {
  border-color: #9BB9D5;
  background: #F8FBFF;
}

.table-pref-bar {
  border: 1px solid var(--pli-line);
  border-radius: var(--radius-md);
  background: var(--pli-white);
}

.table-pref-menu summary {
  border: 1px solid var(--pli-line);
  border-radius: var(--radius);
  color: var(--pli-primary);
  background: var(--pli-bg-soft);
}

/* Drawers and previews */
.preview-drawer {
  width: min(760px, 94vw);
  border-left: 1px solid var(--pli-line);
  background: var(--pli-white);
  box-shadow: var(--shadow-drawer);
}

.preview-drawer-head {
  gap: 14px;
  border-bottom: 1px solid var(--pli-line);
}

.preview-drawer-head h2 {
  color: var(--pli-primary);
}

.document-preview,
.pdf-preview,
.pdf-page-preview,
.spreadsheet-preview,
.docx-preview,
.dxf-preview,
.image-preview,
.empty-preview {
  border: 1px solid var(--pli-line);
  border-radius: var(--radius-md);
  background: var(--pli-white);
}

/* Project center */
.project-workspace {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 18px;
}

.project-side-tabs {
  align-self: start;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--pli-line);
  border-radius: var(--radius-md);
  background: var(--pli-white);
}

.project-tab-button {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 12px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--pli-secondary);
  background: transparent;
  text-align: left;
}

.project-tab-button:hover,
.project-tab-button.active {
  color: var(--pli-primary);
  background: var(--pli-bg-soft);
  border-left-color: var(--pli-accent);
}

.project-tab-button span {
  min-width: 0;
}

.project-tab-button small {
  justify-self: end;
  min-width: 24px;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  color: var(--pli-primary);
  background: var(--pli-bg);
  font-weight: 900;
}

/* Chat */
.chat-root {
  background: var(--pli-white);
}

.chat-root .chat-sidebar.panel,
.chat-sidebar {
  background: var(--pli-secondary);
}

.chat-root .chat-sidebar.panel h2,
.chat-sidebar h2,
.chat-root .chat-sidebar.panel .chat-user-strip strong,
.chat-root .chat-sidebar.panel .chat-user-strip small {
  color: var(--pli-white);
}

.chat-conversation {
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.chat-conversation.active,
.chat-conversation:hover {
  background: rgba(255, 255, 255, .15);
  border-left-color: var(--pli-white);
}

.chat-main,
.chat-root .chat-main.panel {
  background: var(--pli-white);
}

.chat-pane-head {
  border-bottom: 2px solid #C8D9EE;
}

.chat-messages {
  border-top: 2px solid #C8D9EE;
  border-bottom: 2px solid #C8D9EE;
}

.chat-bubble,
.chat-message-body > p {
  border: 1px solid #D8DFE9;
  border-radius: 0 16px 16px 16px;
  background: var(--pli-white);
  box-shadow: 0 1px 4px rgba(20, 40, 80, .07);
}

.chat-message.mine .chat-bubble,
.chat-message.mine .chat-message-body > p {
  border-color: #B8D4F0;
  border-radius: 16px 0 16px 16px;
  background: #E8F4FE;
}

.chat-announcement-empty {
  border: 1px dashed var(--pli-line);
  border-radius: var(--radius-md);
  background: var(--pli-bg-soft);
}

.chat-announcement-empty-mark {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 900;
  color: var(--pli-primary);
  text-transform: uppercase;
}

/* Login gate */
.access-hero {
  background: var(--pli-hero);
}

.access-panel {
  background: var(--pli-white);
}

.access-card h2,
.access-copy h1,
.access-brand-lockup strong {
  letter-spacing: 0;
}

.access-logo {
  width: 260px;
  max-width: 78%;
}

@media (max-width: 980px) {
  .shell,
  .role-layout .project-shell {
    width: 100%;
    margin-left: 0;
  }

  .sidebar {
    position: static;
    width: auto;
    height: auto;
    min-height: auto;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .shell,
  .role-layout .project-shell,
  .standalone-page .project-shell {
    padding: 18px;
  }

  .topbar,
  .project-header,
  .panel-heading {
    display: grid;
    grid-template-columns: 1fr;
  }

  .actions,
  .top-actions,
  .panel-heading-actions {
    justify-content: flex-start;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .project-tab-button {
    grid-template-columns: 18px minmax(0, 1fr) auto;
  }

  .preview-drawer {
    width: 100vw;
  }
}

/* Canonical content inset: operational text and controls never touch panel edges. */
body:not(.review-page) .panel:not(.chat-main):not(.chat-sidebar) {
  padding: 20px;
}

body:not(.review-page) .panel:not(.chat-main):not(.chat-sidebar) > .panel-heading:first-child {
  margin-top: 0;
}

.coming-soon-banner {
  display: grid;
  gap: 6px;
  margin: 14px 0;
  padding: 18px 20px;
  border: 1px solid #B8D4F0;
  border-left: 5px solid var(--pli-secondary);
  border-radius: var(--radius-md);
  color: var(--pli-primary);
  background: #EEF6FD;
}

.coming-soon-banner strong {
  font-family: var(--font-display);
  font-size: 18px;
}

.coming-soon-banner span {
  color: #475467;
  line-height: 1.5;
}

.feature-pending-content {
  display: none !important;
}
