:root {
  --ink: #17232d;
  --ink-soft: #52616d;
  --paper: #ffffff;
  --canvas: #eef1f3;
  --line: #d9e0e5;
  --line-strong: #bdc8d0;
  --accent: #087f8c;
  --accent-dark: #05616b;
  --accent-soft: #e5f6f7;
  --danger: #a73232;
  --danger-soft: #fdecec;
  --success: #236b4c;
  --success-soft: #e6f4ed;
  --shadow: 0 18px 50px rgba(15, 31, 43, .10);
  --radius: 16px;
  --font: "Noto Sans", "Liberation Sans", "DejaVu Sans", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--ink); font-family: var(--font); background: var(--canvas); }
button, input, select, textarea { font: inherit; }
a { color: inherit; }
button { color: inherit; }

.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; }
.brand-mark { position: relative; display: grid; grid-template-columns: 1fr 1fr; width: 42px; height: 42px; border-radius: 11px; overflow: hidden; background: var(--ink); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.brand-mark i, .brand-mark b { display: grid; place-items: center; font-style: normal; font-weight: 800; font-size: 14px; }
.brand-mark i { color: #fff; }
.brand-mark b { background: var(--accent); color: #fff; }
.brand-copy { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.brand-copy strong { font-size: 15px; letter-spacing: .01em; }
.brand-copy small { margin-top: 4px; color: var(--ink-soft); font-size: 11px; }
.brand-compact .brand-mark { width: 34px; height: 34px; border-radius: 8px; }
.brand-compact .brand-copy small { display: none; }
.brand-compact .brand-copy strong { font-size: 14px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 17px; border: 1px solid transparent; border-radius: 10px; text-decoration: none; cursor: pointer; font-weight: 700; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--accent); color: #fff; box-shadow: 0 8px 20px rgba(8,127,140,.18); }
.button-primary:hover { background: var(--accent-dark); }
.button-secondary { background: #fff; border-color: var(--line-strong); }
.button-secondary:hover, .button-ghost:hover { background: #f7f9fa; }
.button-ghost { background: transparent; border-color: var(--line); }
.button-small { min-height: 34px; padding: 0 12px; border-radius: 8px; font-size: 13px; }
.button-block { width: 100%; }

.app-header { position: sticky; top: 0; z-index: 30; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); }
.header-inner { max-width: 1440px; min-height: 70px; margin: auto; padding: 0 28px; display: flex; align-items: center; gap: 34px; }
.main-nav { display: flex; align-self: stretch; gap: 6px; }
.main-nav a { position: relative; display: flex; align-items: center; padding: 0 15px; text-decoration: none; color: var(--ink-soft); font-weight: 700; font-size: 14px; }
.main-nav a.active, .main-nav a:hover { color: var(--ink); }
.main-nav a.active::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 0; height: 3px; border-radius: 2px 2px 0 0; background: var(--accent); }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.user-name { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-soft); font-size: 13px; }

.page-shell { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 44px 0 70px; }
.narrow-shell { width: min(980px, calc(100% - 40px)); }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 30px; }
.page-heading h1 { margin: 6px 0 5px; font-size: clamp(32px, 5vw, 48px); line-height: 1; letter-spacing: -.04em; }
.page-heading p { margin: 0; color: var(--ink-soft); max-width: 720px; line-height: 1.6; }
.eyebrow { color: var(--accent-dark); font-size: 12px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.heading-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.heading-actions form { margin: 0; }

.flash { margin: 0 0 22px; padding: 14px 17px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.flash-error { color: var(--danger); background: var(--danger-soft); border-color: #efc1c1; }
.flash-success { color: var(--success); background: var(--success-soft); border-color: #b9dfca; }
.flash-info { color: var(--accent-dark); background: var(--accent-soft); border-color: #bfe4e7; }

.document-controls { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 24px; }
.search-form { display: flex; align-items: end; gap: 10px; flex: 1; max-width: 620px; }
.search-box { flex: 1; display: grid; gap: 7px; font-size: 12px; color: var(--ink-soft); font-weight: 700; }
.search-box input { width: 100%; height: 44px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; color: var(--ink); outline: none; }
.search-box input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8,127,140,.12); }
.filter-tabs { display: flex; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.filter-tabs a { padding: 9px 13px; border-radius: 8px; text-decoration: none; color: var(--ink-soft); font-weight: 700; font-size: 13px; }
.filter-tabs a.active { background: var(--ink); color: #fff; }

.document-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 20px; }
.document-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 5px 16px rgba(15,31,43,.04); transition: .2s ease; }
.document-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.document-preview { position: relative; display: block; height: 185px; padding: 24px 29px; overflow: hidden; background: linear-gradient(145deg,#f3f6f7,#e6ebee); text-decoration: none; }
.document-preview::before { content: ""; position: absolute; width: 128px; height: 164px; left: 50%; top: 18px; transform: translateX(-50%); background: #fff; border: 1px solid #d8dfe4; box-shadow: 0 8px 18px rgba(14,29,40,.12); }
.document-type { position: absolute; z-index: 2; right: 10px; top: 10px; padding: 4px 7px; border-radius: 6px; background: rgba(23,35,45,.82); color: #fff; font-size: 9px; letter-spacing: .08em; }
.preview-lines { position: relative; z-index: 2; width: 82px; margin: 22px auto; display: grid; gap: 10px; }
.preview-lines i { display: block; height: 3px; background: #c7d0d6; border-radius: 2px; }
.preview-lines i:nth-child(2) { width: 80%; }
.preview-lines i:nth-child(3) { width: 92%; }
.preview-lines i:nth-child(5) { width: 68%; }
.document-card-body { padding: 16px; }
.document-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; font-weight: 800; }
.document-card-body p { margin: 7px 0 14px; color: var(--ink-soft); font-size: 12px; }
.card-actions { display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.card-actions button { padding: 4px 0; border: 0; background: transparent; color: var(--ink-soft); font-size: 12px; font-weight: 700; cursor: pointer; }
.card-actions button:hover { color: var(--accent-dark); }
.card-actions button.danger:hover { color: var(--danger); }

.empty-state { min-height: 360px; display: grid; place-items: center; align-content: center; text-align: center; padding: 30px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: rgba(255,255,255,.55); }
.empty-state h2 { margin: 20px 0 6px; }
.empty-state p { margin: 0; color: var(--ink-soft); }
.empty-paper { width: 70px; height: 90px; display: grid; place-items: center; border: 2px solid var(--line-strong); border-radius: 7px; background: #fff; box-shadow: 8px 8px 0 #dfe5e9; }
.empty-paper span { font-size: 30px; color: var(--accent); }

.import-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.drop-zone { margin: 28px; min-height: 260px; padding: 40px; border: 2px dashed var(--line-strong); border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; cursor: pointer; background: #f8fafb; transition: .18s ease; }
.drop-zone.dragging, .drop-zone:hover { border-color: var(--accent); background: var(--accent-soft); }
.drop-zone input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop-icon { width: 58px; height: 58px; display: grid; place-items: center; margin-bottom: 18px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 28px; }
.drop-zone strong { font-size: 20px; }
.drop-zone small { max-width: 580px; margin-top: 9px; color: var(--ink-soft); line-height: 1.55; }
.drop-zone em { margin-top: 18px; font-style: normal; color: var(--accent-dark); font-weight: 800; font-size: 13px; }
.import-information { padding: 0 28px 26px; }
.import-information h2 { margin: 0 0 14px; font-size: 20px; }
.import-information > p { margin: 16px 0 0; color: var(--ink-soft); line-height: 1.6; font-size: 13px; }
.info-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.info-grid div { padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfc; }
.info-grid strong { display: block; margin-bottom: 5px; }
.info-grid span { color: var(--ink-soft); font-size: 12px; line-height: 1.45; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 28px; border-top: 1px solid var(--line); background: #f8fafb; }

.version-list { display: grid; gap: 10px; }
.version-row { display: grid; grid-template-columns: 62px 1fr auto; gap: 17px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.version-number { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent-dark); font-weight: 900; }
.version-info { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.version-info strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.version-info span, .version-info small { color: var(--ink-soft); font-size: 12px; }

.site-footer { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 20px 0 28px; display: flex; justify-content: space-between; gap: 20px; color: var(--ink-soft); font-size: 11px; }

.login-page { background: #fff; }
.login-shell { min-height: calc(100vh - 50px); display: grid; grid-template-columns: minmax(420px, 620px) 1fr; }
.login-panel { padding: clamp(30px,6vw,78px); display: flex; flex-direction: column; justify-content: center; }
.login-copy { max-width: 520px; margin: 65px 0 34px; }
.login-copy h1 { margin: 9px 0 18px; font-size: clamp(38px,5vw,64px); letter-spacing: -.055em; line-height: .98; }
.login-copy p { margin: 0; color: var(--ink-soft); line-height: 1.65; }
.login-form { max-width: 440px; display: grid; gap: 16px; }
.login-form label { display: grid; gap: 7px; color: var(--ink-soft); font-size: 12px; font-weight: 800; }
.login-form input { height: 48px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 10px; outline: none; color: var(--ink); background: #fff; }
.login-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8,127,140,.12); }
.login-note { max-width: 440px; margin: 18px 0 0; color: var(--ink-soft); font-size: 11px; line-height: 1.5; }
.login-visual { min-height: 100vh; display: grid; place-items: center; overflow: hidden; background: linear-gradient(145deg,#17232d,#263947); }
.paper-stack { position: relative; width: min(360px,50vw); aspect-ratio: .74; transform: rotate(-4deg); }
.paper-stack > div { position: absolute; inset: 0; border-radius: 8px; background: #fff; box-shadow: 0 30px 70px rgba(0,0,0,.35); }
.paper-stack > div:first-child { transform: translate(28px,22px) rotate(8deg); opacity: .58; }
.paper-stack > div:nth-child(2) { transform: translate(14px,10px) rotate(3deg); opacity: .8; }
.paper-front { padding: 50px; display: flex; flex-direction: column; justify-content: center; }
.paper-front::before { content: ""; position: absolute; left: 50px; right: 50px; top: 50px; height: 8px; background: var(--accent); border-radius: 4px; }
.paper-front span { color: var(--accent-dark); font-weight: 900; letter-spacing: .16em; }
.paper-front strong { margin-top: 12px; font-size: clamp(32px,5vw,58px); line-height: .9; letter-spacing: -.05em; }
.paper-front i { margin-top: 22px; color: var(--ink-soft); font-style: normal; }

@media (max-width: 920px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .header-inner { padding: 0 16px; gap: 14px; }
  .main-nav { display: none; }
  .user-name { display: none; }
  .page-shell { width: min(100% - 28px, 1440px); padding-top: 28px; }
  .page-heading, .document-controls { align-items: stretch; flex-direction: column; }
  .search-form { max-width: none; }
  .filter-tabs { align-self: flex-start; }
  .info-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .brand-copy small { display: none; }
  .page-heading h1 { font-size: 36px; }
  .heading-actions, .heading-actions form, .heading-actions .button { width: 100%; }
  .document-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .document-preview { height: 135px; padding: 14px; }
  .document-preview::before { width: 92px; height: 118px; top: 10px; }
  .preview-lines { width: 58px; margin-top: 16px; gap: 7px; }
  .document-card-body { padding: 12px; }
  .card-actions { flex-direction: column; align-items: flex-start; }
  .filter-tabs { width: 100%; overflow-x: auto; }
  .filter-tabs a { flex: 1; text-align: center; }
  .search-form { flex-wrap: wrap; }
  .search-form .button { width: 100%; }
  .drop-zone { margin: 14px; padding: 24px 14px; }
  .import-information { padding: 0 14px 20px; }
  .form-actions { padding: 14px; }
  .version-row { grid-template-columns: 48px 1fr; }
  .version-row form { grid-column: 1 / -1; }
  .version-row .button { width: 100%; }
  .site-footer { width: calc(100% - 28px); flex-direction: column; }
}
.import-tabs { display: flex; gap: 4px; margin: 24px 28px 0; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: #f5f7f8; }
.import-tabs button { flex: 1; min-height: 38px; border: 0; border-radius: 7px; background: transparent; color: var(--ink-soft); cursor: pointer; font-weight: 800; }
.import-tabs button.active { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgba(15,31,43,.08); }
.url-import { margin: 28px; padding: 24px; border: 1px solid var(--line); border-radius: 12px; background: #f8fafb; }
.url-import label { display: grid; gap: 8px; font-size: 12px; font-weight: 800; color: var(--ink-soft); }
.url-import input { height: 44px; padding: 0 13px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; color: var(--ink); }
.url-import p { margin: 10px 0 0; color: var(--ink-soft); font-size: 11px; }

/* Corrección 0.1.1: ajuste exacto a PC, tablet y celular. */
html, body { max-width: 100%; overflow-x: hidden; }
.login-page { min-height: 100dvh; display: grid; grid-template-rows: minmax(0,1fr) auto; }
.login-shell { width: 100%; min-height: 0; height: 100%; grid-template-columns: minmax(360px, 48%) minmax(0, 52%); }
.login-panel { min-width: 0; padding: clamp(28px, 4.7vw, 72px); }
.login-copy { margin: clamp(32px, 6vh, 62px) 0 clamp(24px, 4vh, 34px); }
.login-copy h1 { font-size: clamp(38px, 4.7vw, 62px); }
.login-visual { min-width: 0; min-height: 0; height: 100%; }
.paper-stack { width: min(360px, 58%); max-height: 72vh; }
.paper-front { padding: clamp(34px, 4vw, 50px); }
.paper-front strong { font-size: clamp(28px, 3.4vw, 46px); white-space: nowrap; overflow-wrap: normal; }
.login-page .site-footer { width: 100%; min-height: 50px; padding: 13px 24px; background: #fff; }

@media (min-width: 921px) and (max-height: 820px) {
  .login-panel { padding-top: 26px; padding-bottom: 26px; }
  .login-copy { margin-top: 28px; margin-bottom: 22px; }
  .login-copy h1 { font-size: clamp(34px, 4.3vw, 52px); }
  .login-form { gap: 12px; }
  .login-form input { height: 44px; }
  .paper-stack { max-height: 66vh; }
}

@media (min-width: 721px) and (max-width: 1100px) {
  .login-shell { grid-template-columns: minmax(360px, 56%) minmax(0, 44%); }
  .login-panel { padding: clamp(28px, 4vw, 48px); }
  .paper-stack { width: min(310px, 72%); }
  .paper-front { padding: 34px; }
  .paper-front::before { left: 34px; right: 34px; top: 36px; }
  .paper-front strong { font-size: clamp(28px, 4vw, 42px); }
}

@media (max-width: 920px) {
  .login-page { display: block; min-height: 100dvh; }
  .login-shell { min-height: calc(100dvh - 70px); height: auto; grid-template-columns: 1fr; }
  .login-panel { width: min(620px, 100%); margin: 0 auto; justify-content: flex-start; padding: clamp(28px, 7vw, 56px) clamp(20px, 6vw, 48px); }
  .login-copy { margin: clamp(36px, 7vh, 64px) 0 28px; }
  .login-copy h1 { font-size: clamp(38px, 9vw, 58px); }
  .login-form, .login-note { max-width: none; }
}

@media (max-width: 560px) {
  .login-panel { padding: 24px 18px 34px; }
  .login-copy { margin: 38px 0 24px; }
  .login-copy h1 { font-size: clamp(36px, 12vw, 48px); line-height: 1; }
  .login-copy p { font-size: 14px; }
  .login-page .site-footer { width: 100%; padding: 14px 18px 20px; }
}
