:root {
  color-scheme: light;
  --ink: #17221f;
  --muted: #66716d;
  --line: #dfe5e1;
  --soft: #f3f6f4;
  --paper: #f7f9f7;
  --white: #ffffff;
  --forest: #163b32;
  --forest-deep: #0d2923;
  --sage: #a9c7b4;
  --mint: #dcebe2;
  --gold: #c7a96c;
  --danger: #a93c32;
  --focus: #247d67;
  font-family: "Manrope", Arial, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
}

.sidebar {
  position: fixed;
  z-index: 5;
  inset: 0 auto 0 0;
  width: 244px;
  display: flex;
  flex-direction: column;
  padding: 30px 22px 24px;
  color: #f4f8f5;
  background:
    radial-gradient(circle at 10% 90%, rgb(169 199 180 / 12%), transparent 28%),
    var(--forest-deep);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 9px;
  color: var(--forest-deep);
  background: var(--mint);
  font-family: "Manrope", Arial, sans-serif;
  font-size: 19px;
}

.main-nav {
  margin-top: 52px;
}

.main-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  border-radius: 8px;
  padding: 0 13px;
  color: rgb(244 248 245 / 68%);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

.main-nav a[aria-current="page"] {
  color: #fff;
  background: rgb(255 255 255 / 9%);
}

.nav-mark {
  width: 14px;
  height: 17px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  box-shadow: inset 0 4px 0 transparent;
}

.sidebar-principle {
  margin-top: auto;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 10px;
  padding: 16px;
}

.sidebar-principle p {
  margin: 0 0 7px;
  color: var(--sage);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-principle strong {
  color: rgb(244 248 245 / 82%);
  font-family: "Manrope", Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
}

.back-link {
  margin: 20px 4px 0;
  color: rgb(244 248 245 / 50%);
  font-size: 11px;
  text-decoration: none;
}

.sidebar .back-link.session-sign-out {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 38px;
  margin: 14px 0 0;
  border: 1px solid rgb(244 248 245 / 18%);
  border-radius: 8px;
  padding: 8px 12px;
  color: #f4f8f5;
  background: rgb(255 255 255 / 7%);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.sidebar .back-link.session-sign-out:hover {
  border-color: rgb(244 248 245 / 28%);
  background: rgb(255 255 255 / 12%);
}

.sidebar .back-link.session-sign-out:focus-visible {
  outline: 3px solid rgb(169 199 180 / 48%);
  outline-offset: 2px;
}

.workspace {
  min-width: 0;
  grid-column: 2;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 30px;
  border-bottom: 1px solid var(--line);
  padding: 0 clamp(24px, 4vw, 58px);
  background: rgb(255 255 255 / 92%);
}

.mobile-brand {
  display: none;
}

.preview-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.preview-status > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3e9b73;
  box-shadow: 0 0 0 4px rgb(62 155 115 / 12%);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 1px solid var(--line);
  padding-left: 28px;
  font-size: 12px;
}

.avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: var(--forest);
  background: var(--mint);
  font-size: 11px;
  font-weight: 750;
}

.user-menu strong,
.user-menu small {
  display: block;
}

.user-menu small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.content {
  max-width: 1380px;
  margin: 0 auto;
  padding: 48px clamp(24px, 4.5vw, 68px) 80px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--focus);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.page-heading h1 {
  margin: 0;
  font-family: "Manrope", Arial, sans-serif;
  font-size: clamp(36px, 4vw, 52px);
  font-weight: 400;
  letter-spacing: -0.03em;
}

.page-heading > div > p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 700;
}

.primary-button {
  border: 1px solid var(--forest);
  color: var(--white);
  background: var(--forest);
}

.primary-button:hover {
  background: var(--forest-deep);
}

.primary-button > span {
  margin-right: 7px;
  font-size: 18px;
  font-weight: 400;
}

.secondary-button {
  border: 1px solid #c5cec9;
  color: var(--forest);
  background: var(--white);
}

.danger-button {
  border: 1px solid #ddbeb9;
  color: var(--danger);
  background: #fffafa;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.35fr;
  gap: 16px;
  margin-top: 38px;
}

.summary-grid article {
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 24px;
  background: var(--white);
}

.summary-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.summary-grid strong {
  margin: 8px 0 3px;
  font-family: "Manrope", Arial, sans-serif;
  font-size: 29px;
  font-weight: 400;
}

.summary-grid small {
  color: #89928e;
  font-size: 11px;
}

.summary-grid .principle-card {
  border-color: transparent;
  color: #f4f8f5;
  background: var(--forest);
}

.principle-card .summary-label,
.principle-card small {
  color: rgb(244 248 245 / 62%);
}

.principle-card strong {
  font-family: "Manrope", Arial, sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.case-section {
  margin-top: 42px;
}

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

.section-toolbar h2 {
  margin: 0;
  font-family: "Manrope", Arial, sans-serif;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.045em;
}

.section-toolbar p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.filters {
  display: flex;
  gap: 10px;
}

.filters input,
.filters select,
.form-field input,
.drawer-field input,
.drawer-field select {
  height: 42px;
  border: 1px solid #cbd4cf;
  border-radius: 8px;
  outline: none;
  padding: 0 12px;
  color: var(--ink);
  background: var(--white);
}

.filters input {
  width: min(260px, 32vw);
}

.filters input:focus,
.filters select:focus,
.form-field input:focus,
.drawer-field input:focus,
.drawer-field select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgb(36 125 103 / 12%);
}

.case-table-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 17px 20px;
  text-align: left;
}

th {
  border-bottom: 1px solid var(--line);
  color: #7c8782;
  background: #fbfcfb;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

td {
  border-bottom: 1px solid #edf0ee;
  color: #46514d;
  font-size: 12px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fbfcfb;
}

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

.case-initial {
  display: grid;
  width: 35px;
  height: 35px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  color: var(--forest);
  background: var(--mint);
  font-family: "Manrope", Arial, sans-serif;
  font-size: 15px;
}

.case-name strong {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.case-archived-pill {
  border-radius: 999px;
  padding: 3px 7px;
  color: #6e6758;
  background: #f0eee9;
  font-size: 9px;
  font-style: normal;
  font-weight: 700;
  white-space: nowrap;
}

.case-select-button {
  border: 1px solid #b7d5c5;
  border-radius: 999px;
  padding: 6px 11px;
  color: #0d5c45;
  background: #fff;
  font: inherit;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
  white-space: nowrap;
}

.case-select-button:hover:not(:disabled) { background: #edf7f0; }
.case-select-button:focus-visible { outline: 3px solid #d6a84f; outline-offset: 2px; }
.case-select-button.selected {
  border-color: transparent;
  color: #0d4a37;
  background: #dcefe6;
  cursor: default;
}

.case-name small {
  display: block;
  margin-top: 3px;
  color: #8b9590;
  font-size: 10px;
}

.case-documents-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  margin-top: 3px;
  padding: 0;
  color: #8b9590;
  background: transparent;
  font-size: 10px;
  font-weight: 650;
}

.case-documents-toggle:hover {
  color: var(--focus);
}

.case-documents-row td {
  padding-top: 0;
  background: #fbfcfb;
}

.case-documents-panel {
  margin-left: 47px;
  border: 1px solid #e7ece9;
  border-radius: 10px;
  padding: 12px;
  background: #fff;
}

.case-documents-empty {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.case-documents-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.case-document-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
}

.case-document-item.error {
  border-color: #edd1cc;
  background: #fffafa;
}

.case-document-main,
.case-document-status,
.case-document-detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.case-document-main strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 11px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-document-main span,
.case-document-status,
.case-document-detail small {
  color: var(--muted);
  font-size: 9px;
}

.case-document-status {
  margin-top: 9px;
}

.case-document-detail {
  margin-top: 8px;
}

.case-document-detail small {
  line-height: 1.45;
}

.delete-failed-document {
  flex: 0 0 auto;
  border: 0;
  padding: 2px 0;
  color: var(--danger);
  background: transparent;
  font-size: 10px;
  font-weight: 800;
}

.delete-failed-document:hover {
  color: #7e2119;
}

.status-pill,
.access-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 10px;
  font-weight: 700;
}

.status-pill.active {
  color: #286349;
  background: #e6f2eb;
}

.status-pill.archived {
  color: #6e6758;
  background: #f0eee9;
}

.access-pill {
  border: 1px solid var(--line);
  color: #5f6a65;
  background: #fbfcfb;
}

.manage-button {
  border: 0;
  color: var(--focus);
  background: transparent;
  font-size: 11px;
  font-weight: 750;
}

.empty-state {
  padding: 68px 20px;
  text-align: center;
}

.empty-state > span {
  display: grid;
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  place-items: center;
  border-radius: 50%;
  color: var(--forest);
  background: var(--mint);
  font-family: "Manrope", Arial, sans-serif;
}

.empty-state h3 {
  margin: 0;
  font-family: "Manrope", Arial, sans-serif;
  font-size: 20px;
  font-weight: 400;
}

.empty-state p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.modal {
  width: min(92vw, 520px);
  border: 0;
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 25px 80px rgb(13 41 35 / 25%);
}

.modal::backdrop {
  background: rgb(13 41 35 / 55%);
  backdrop-filter: blur(2px);
}

.modal form {
  padding: 28px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.modal h2,
.case-drawer h2 {
  margin: 0;
  font-family: "Manrope", Arial, sans-serif;
  font-size: 28px;
  font-weight: 400;
}

.close-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--white);
  font-size: 20px;
}

.modal-copy {
  margin: 18px 0 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.form-field,
.drawer-field {
  display: grid;
  gap: 8px;
  color: #35423d;
  font-size: 12px;
  font-weight: 700;
}

.form-error {
  min-height: 17px;
  margin: 7px 0 0;
  color: var(--danger);
  font-size: 11px;
}

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

.drawer-backdrop {
  position: fixed;
  z-index: 10;
  inset: 0;
  background: rgb(13 41 35 / 24%);
}

.case-drawer {
  position: fixed;
  z-index: 11;
  top: 0;
  right: 0;
  width: min(92vw, 460px);
  height: 100vh;
  overflow-y: auto;
  transform: translateX(102%);
  padding: 30px;
  background: var(--white);
  box-shadow: -20px 0 70px rgb(13 41 35 / 17%);
  transition: transform 180ms ease;
}

.case-drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.drawer-meta {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.drawer-section {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

.drawer-section h3 {
  margin: 0 0 6px;
  font-size: 13px;
}

.drawer-section > p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.document-empty {
  margin: -2px 0 14px !important;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}

.document-list {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.document-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  font-size: 11px;
}

.document-list span {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-list small {
  flex: 0 0 auto;
  color: var(--muted);
}

.upload-zone {
  display: grid;
  gap: 5px;
  border: 1px dashed #aebcb5;
  border-radius: 10px;
  padding: 18px;
  color: var(--focus);
  background: var(--soft);
  text-align: center;
  cursor: pointer;
}

.upload-zone:hover {
  border-color: var(--focus);
  background: #eef5f1;
}

.upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.upload-zone span {
  font-size: 12px;
  font-weight: 800;
}

.upload-zone small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.upload-zone:has(input:focus-visible) {
  outline: 3px solid rgb(36 125 103 / 18%);
  outline-offset: 2px;
}

.upload-zone:has(input:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
}

.selected-document-name {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  background: #fbfcfb;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.selected-document-name.has-file {
  border-color: #b9d8c7;
  background: #f1faf5;
  color: #123b2f;
  font-weight: 700;
}

.upload-status {
  min-height: 17px;
  margin: 0 !important;
  color: var(--muted) !important;
  font-size: 11px !important;
}

.upload-progress-panel {
  display: block;
}

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

.drawer-form {
  display: grid;
  gap: 12px;
}

.drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.drawer-actions button {
  flex: 1 1 150px;
}

.drawer-action-note {
  margin: 10px 0 0;
  color: var(--muted, #667085);
  font-size: 0.875rem;
  line-height: 1.45;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 24px;
  bottom: 24px;
  max-width: 340px;
  border-radius: 9px;
  padding: 13px 17px;
  color: #fff;
  background: var(--forest-deep);
  box-shadow: 0 10px 35px rgb(13 41 35 / 25%);
  font-size: 12px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

@media (max-width: 960px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .workspace {
    display: block;
  }

  .topbar {
    justify-content: space-between;
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .mobile-brand .brand-mark {
    width: 30px;
    height: 30px;
  }

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

  .principle-card {
    grid-column: 1 / -1;
  }

}

@media (max-width: 700px) {
  .topbar {
    height: 64px;
    padding: 0 18px;
  }

  .preview-status,
  .user-menu > span:last-child {
    display: none;
  }

  .user-menu {
    border: 0;
    padding: 0;
  }

  .content {
    padding: 34px 18px 60px;
  }

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

  .page-heading .primary-button {
    width: 100%;
  }

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

  .summary-grid article {
    min-height: 112px;
    padding: 18px;
  }

  .principle-card {
    display: none !important;
  }


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

  .filters {
    display: grid;
    grid-template-columns: 1fr;
  }

  .filters input,
  .filters select {
    width: 100%;
  }

  th:nth-child(3),
  td:nth-child(3),
  th:nth-child(4),
  td:nth-child(4) {
    display: none;
  }

  th,
  td {
    padding: 14px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}

/* Sistema tipográfico inspirado en Apex. */
.brand-mark,
.eyebrow,
.summary-label,
th,
.case-initial {
  font-family: "DM Mono", monospace;
}

.eyebrow,
th {
  font-weight: 500;
}

.page-heading h1 {
  font-family: "Manrope", Arial, sans-serif;
  font-weight: 800;
  letter-spacing: -0.065em;
}

.summary-grid strong {
  font-family: "Manrope", Arial, sans-serif;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.empty-state h3,
.modal h2,
.case-drawer h2 {
  font-family: "Manrope", Arial, sans-serif;
  font-weight: 800;
  letter-spacing: -0.045em;
}


/* Estados documentales de la demostración local. */
.document-list li {
  display: block;
}

.document-row,
.processing-row,
.processing-detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.document-row > span {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-row > small {
  flex: 0 0 auto;
  color: var(--muted);
}

.processing-row {
  margin-top: 10px;
  color: var(--muted);
  font-size: 9px;
}

.processing-status {
  font-weight: 800;
}

.processing-status.success {
  color: #286349;
}

.processing-status.working {
  color: var(--focus);
}

.processing-status.error {
  color: var(--danger);
}

.processing-track {
  display: block;
  width: 100%;
  height: 5px;
  border: 0;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
  appearance: none;
  background: #e9eeeb;
}

.processing-track::-webkit-progress-bar {
  border-radius: inherit;
  background: #e9eeeb;
}

.processing-track::-webkit-progress-value {
  border-radius: inherit;
  background: var(--focus);
}

.processing-track::-moz-progress-bar {
  border-radius: inherit;
  background: var(--focus);
}

.document-item.error .processing-track::-webkit-progress-value {
  background: var(--danger);
}

.document-item.error .processing-track::-moz-progress-bar {
  background: var(--danger);
}

.processing-detail {
  margin-top: 8px;
}

.processing-detail small {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.retry-document {
  flex: 0 0 auto;
  border: 0;
  padding: 2px 0;
  color: var(--focus);
  background: transparent;
  font-size: 10px;
  font-weight: 800;
}
.document-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.open-document {
  color: var(--focus);
  font-size: 10px;
  font-weight: 800;
  text-decoration: none;
}

.open-document:hover {
  text-decoration: underline;
}
