/* Shared screen interface. Clinical paper layout lives in clinical-documents.css. */
@media screen {
  .modern-ui {
    --text: #213c50;
    --text-secondary: #526d80;
    --muted: #566f82;
    --border: #dfe9f0;
    --radius-lg: 18px;
    background: #f2f6fa;
    color: var(--text);
  }

  .modern-ui .app-topbar,
  .modern-ui .public-topbar {
    background: #ffffff;
    border-bottom: 1px solid #dce8f0;
    box-shadow: 0 3px 18px #123e5805;
  }

  .modern-ui .app-topbar {
    padding: 16px 28px;
    gap: 16px;
    border-top: 3px solid #0b69a3;
  }

  .modern-ui .brand-logo {
    max-height: 44px;
    max-width: 130px;
  }

  .modern-ui .brand-text h1 {
    font-size: 16px;
    letter-spacing: -.02em;
  }

  .modern-ui .brand-text p { font-size: 12px; }

  .modern-ui .topnav { gap: 4px; }

  .modern-ui .topnav .btn,
  .modern-ui .topnav .private-top-menu summary {
    border-radius: 9px;
    padding: 9px 10px;
    font-size: 12px;
  }

  .modern-ui .topnav .btn:hover,
  .modern-ui .topnav .private-top-menu summary:hover { background: #edf6fb; }

  .modern-ui .container {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 24px 32px;
  }

  .modern-ui .card {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 26px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px #153f5706;
    transition: none;
  }

  .modern-ui .card:hover {
    border-color: var(--border);
    box-shadow: 0 4px 20px #153f5706;
  }

  .modern-ui .card h2 { font-size: 18px; letter-spacing: -.025em; }
  .modern-ui .field { min-width: 0; }

  .modern-ui .field label {
    display: block;
    margin-bottom: 7px;
    color: #39576b;
    font-size: 12px;
    font-weight: 600;
  }

  .modern-ui .field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
  .modern-ui .field select,
  .modern-ui textarea,
  .modern-ui .topbar-history input {
    min-width: 0;
    min-height: 44px;
    border: 1px solid #d7e3ec;
    border-radius: 10px;
    padding: 11px 13px;
    background: #f8fbfd;
    color: #213c50;
    box-shadow: inset 0 1px 2px #153f5703;
    font-family: inherit;
    font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
  }

  .modern-ui textarea { width: 100%; resize: vertical; line-height: 1.6; }
  .modern-ui .field input[type="file"] {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 9px;
    border: 1px dashed #c8dbe8;
    border-radius: 10px;
    background: #f8fbfd;
    color: #526d80;
    font-size: 12px;
  }
  .modern-ui input[type="file"]::file-selector-button {
    margin-right: 10px;
    padding: 7px 10px;
    border: 0;
    border-radius: 7px;
    background: #e1eff8;
    color: #0b69a3;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
  }
  .modern-ui .preview-box {
    display: grid;
    place-items: center;
    min-height: 90px;
    padding: 12px;
    margin-top: 10px;
    border: 1px solid #e0e9f0;
    border-radius: 10px;
    background: #fcfdff;
  }
  .modern-ui .preview-box img { max-width: 100%; max-height: 110px; object-fit: contain; }
  .modern-ui .preview-box img:not([src]),
  .modern-ui .preview-box img[src=""] { display: none; }
  .modern-ui .preview-box:has(img:not([src]), img[src=""])::before {
    content: 'Sin imagen cargada';
    color: #657e90;
    font-size: 12px;
  }
  .modern-ui .card > :is(.grid-2, .grid-3) + :is(.actions-row, .grid-2) { margin-top: 18px; }
  .modern-ui input::placeholder,
  .modern-ui textarea::placeholder { color: #7c91a0; opacity: 1; }

  .modern-ui .field input:focus,
  .modern-ui .field select:focus,
  .modern-ui textarea:focus,
  .modern-ui .topbar-history input:focus {
    border-color: #0b69a3;
    box-shadow: 0 0 0 3px #0b69a314;
    outline: 0;
    background: #fff;
  }

  .modern-ui :is(button, a, summary, input, select, textarea):focus-visible {
    outline: 3px solid #0b69a3;
    outline-offset: 3px;
  }

  .modern-ui input[type="checkbox"],
  .modern-ui input[type="radio"] { accent-color: #0b69a3; }

  .modern-ui .btn {
    min-height: 42px;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    box-shadow: none;
    transition: background .15s, border-color .15s;
  }

  .modern-ui .btn.primary {
    background: #0b69a3;
    border-color: #0b69a3;
    color: #fff;
    box-shadow: 0 3px 8px #0b69a31a;
  }

  .modern-ui .btn.primary:hover { background: #075788; border-color: #075788; }
  .modern-ui .btn.secondary { background: #f2f7fb; border-color: #dce8f0; color: #315b76; }
  .modern-ui .btn.danger { background: #fff; border-color: #ecd9dc; color: #a1414e; }
  .modern-ui .btn:disabled { opacity: .55; cursor: wait; transform: none; }

  .workspace-intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 16px;
    padding: 12px 20px;
    border: 1px solid #dce8f0;
    border-left: 4px solid #0b69a3;
    border-radius: 0 18px 18px 0;
    background: #fff;
  }

  .interface-eyebrow {
    margin: 0 0 2px;
    color: #0b69a3;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .14em;
  }

  .workspace-intro h2 { margin: 0; font-size: 22px; line-height: 1.2; letter-spacing: -.04em; }
  .workspace-intro > div > p:last-child { margin: 4px 0 0; color: var(--text-secondary); font-size: 12px; line-height: 1.5; }

  .workspace-format {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border: 1px solid #d6e9f4;
    border-radius: 13px;
    background: #eaf5fc;
    color: #0b69a3;
  }

  .workspace-format > span { font-size: 22px; line-height: 1; }
  .workspace-format strong { display: block; font-size: 12px; }
  .workspace-format div > span { display: block; margin-top: 2px; color: #4e738b; font-size: 11px; }

  .interface-section-heading { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid #e8eff4; }
  .interface-section-heading h2 { margin: 0 0 3px !important; }
  .interface-section-heading p { margin: 0; color: var(--text-secondary); font-size: 12px; }
  .interface-step { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 36px; border: 1px solid #d6e9f4; border-radius: 10px; background: #eaf5fc; color: #0b69a3; font-size: 11px; font-weight: 700; }

  .clinical-workspace .patient-card .grid-4 {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, .65fr) minmax(0, 1.6fr) minmax(0, 1.15fr);
    gap: 16px;
  }

  .clinical-workspace .patient-card .field { margin: 0; }
  .clinical-workspace .patient-card .field small:empty { display: none; }

  .clinical-workspace :is(.patient-card, .document-choice-card) { padding: 12px 16px; margin-bottom: 8px; }
  .clinical-workspace :is(.patient-card, .document-choice-card) .interface-section-heading {
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    padding-bottom: 8px;
  }
  .clinical-workspace :is(.patient-card, .document-choice-card) .interface-section-heading > div {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 2px 12px;
  }
  .clinical-workspace :is(.patient-card, .document-choice-card) .interface-section-heading h2 { margin: 0 !important; font-size: 16px; }
  .clinical-workspace :is(.patient-card, .document-choice-card) .interface-section-heading p { font-size: 11px; }
  .clinical-workspace :is(.patient-card, .document-choice-card) .interface-step { width: 28px; height: 28px; flex-basis: 28px; border-radius: 8px; font-size: 10px; }
  .clinical-workspace .patient-card .grid-4 { gap: 10px 12px; }
  .clinical-workspace .patient-card .field label { margin-bottom: 4px; font-size: 11px; }
  .clinical-workspace .patient-card .field input { min-height: 40px; padding: 8px 10px; font-size: 13px; }

  .clinical-workspace .document-choices {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .clinical-workspace .document-choices .chip {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
    padding: 10px;
    border: 1px solid #e0e9f0;
    border-radius: 12px;
    background: #fcfdff;
    cursor: pointer;
    transition: border-color .15s, background .15s;
  }

  .clinical-workspace .document-choices .chip:hover { border-color: #92bed8; background: #f5faff; }
  .clinical-workspace .document-choices .chip:last-child { grid-column: 1 / -1; }
  .clinical-workspace .document-choices .mentenota-workspace-link { text-decoration: none; color: inherit; }
  .clinical-workspace .document-choices .mentenota-workspace-link[hidden] { display: none !important; }
  .clinical-workspace .document-choices .chip:has(input:checked) { background: #eaf5fc; border-color: #0b69a3; box-shadow: inset 0 0 0 1px #0b69a3; }
  .clinical-workspace .document-choices .chip:has(input:disabled) { opacity: .5; cursor: not-allowed; }
  .clinical-workspace .document-choices input { width: 17px; height: 17px; flex: 0 0 17px; margin: 2px 0 0; }
  .choice-copy { min-width: 0; }
  .choice-copy strong { display: block; color: #294c65; font-size: 12px; font-weight: 600; line-height: 1.4; }
  .choice-copy small { display: block; margin-top: 2px; color: #526d80; font-size: 11px; font-weight: 400; line-height: 1.4; }

  .clinical-workspace .subsections details { border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
  .clinical-workspace .subsections summary { color: #315b76; font-size: 14px; }
  .clinical-workspace .subsections details[open] summary { padding-bottom: 14px; }
  .clinical-workspace .subsections .grid-4 > label { display: flex; align-items: flex-start; gap: 8px; color: #3b566a; font-size: 13px; line-height: 1.5; }
  .clinical-workspace .tipo-doc-selector { background: #f1f8fc; border-color: #d6e9f4; border-radius: 12px; }
  .clinical-workspace .tipo-doc-chip { background: #fff; border-radius: 9px; border: 1px solid #d6e4ed; color: #426078; box-shadow: none; font-size: 12px; }
  .clinical-workspace .tipo-doc-chip.active,
  .clinical-workspace #tipoLicencia.active { background: #0b69a3; color: #fff; border-color: #0b69a3; box-shadow: none; }
  .clinical-workspace .ficha-ai-panel { background: #f8fbfd; border-color: #dfe9f0; border-radius: 14px; }
  .clinical-workspace .ficha-ai-head h3 { color: #294c65; }
  .clinical-workspace .peritaje-toolbar { border-radius: 12px 12px 0 0; background: #f6f9fc; }
  .clinical-workspace .peritaje-editor { border-radius: 0 0 12px 12px; font-size: 15px; line-height: 1.65; }
  .clinical-workspace .peritaje-editor:focus { border-color: #0b69a3; box-shadow: 0 0 0 3px #0b69a314; }
  .clinical-workspace .toolbar-btn:hover { color: #0b69a3; border-color: #92bed8; background: #eaf5fc; transform: none; box-shadow: none; }

  .clinical-workspace .container { max-width: 1480px; margin-top: 18px; margin-bottom: 12px; padding-bottom: 12px; }
  .clinical-layout { display: grid; grid-template-columns: minmax(0, 1fr) 248px; align-items: start; gap: 24px; }
  .clinical-main { min-width: 0; }
  .clinical-workspace .document-actions {
    position: sticky;
    top: calc(var(--workspace-header-height, 104px) + 20px);
    /* Leave the bottom corner free for the existing Tasks launcher. */
    max-height: min(calc(100svh - var(--workspace-header-height, 104px) - 100px), calc(100svh - var(--workspace-actions-offset, 260px)));
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #c1d5e3 transparent;
    scrollbar-gutter: stable;
    padding: 18px;
    margin-bottom: 0;
    background: #fff;
    box-shadow: 0 4px 20px #153f5706;
  }
  .clinical-workspace .document-actions h2 { margin: 0 0 16px; font-size: 15px; line-height: 1.4; }
  .clinical-workspace .document-actions .actions-row { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
  .clinical-workspace .document-actions .btn { width: 100%; min-width: 0; text-align: left; min-height: 44px; }
  .clinical-workspace .document-actions #btnLimpiarPaciente { margin: 12px 0 0; }
  .document-actions .pdf-margin-controls { flex-direction: column; align-items: stretch; }
  .document-actions .pdf-margin-controls label { justify-content: space-between; }
  .document-actions .document-output-status { margin-top: 16px; padding-top: 14px; border-top: 1px solid #e8eff4; overflow-wrap: anywhere; }
  .clinical-workspace .actions-row { gap: 8px; }
  .pdf-layout-settings { margin-top: 12px; font-size: 12px; color: #526d80; }
  .pdf-layout-settings > summary { cursor: pointer; width: fit-content; }
  .pdf-layout-settings .pdf-margin-controls { margin: 12px 0 0; padding: 12px; border-radius: 10px; background: #f4f8fb; }
  .clinical-workspace .document-output-status { font-size: 12px; line-height: 1.5; }
  .clinical-workspace .preview-wrapper { padding: 24px; border: 1px solid #dce6ee; border-radius: 18px; background: #eaf0f5; }
  .clinical-workspace .document-preview-heading { margin: 0 0 4px; color: #294c65; font-size: 17px; }
  .clinical-workspace #documentPreviewDetail { margin: 0 0 20px; font-size: 12px; }
  .clinical-workspace .email-confirm-dialog { border-radius: 18px; border: 1px solid #d6e4ed; box-shadow: 0 24px 80px #153f5729; }

  .modern-ui.landing-page { background: #f7fafc; }
  .modern-ui.landing-page .booking-panel { border-radius: 20px; box-shadow: 0 4px 24px #153f5708; }
  .modern-ui.landing-page .professional-booking:hover { background: #eaf5fc; border-color: #c5e2f3; }
  .modern-ui.landing-page .public-login { background: #0b69a3; border-color: #0b69a3; color: #fff; border-radius: 10px; }
  .modern-ui.landing-page .landing-gallery { border-radius: 20px; }
  .modern-ui.login-page { background: #f2f6fa; }
  .modern-ui .login-panel { background: #fff; border-radius: 22px; border: 1px solid #dce8f0; border-top: 4px solid #0b69a3; box-shadow: 0 12px 48px #153f570a; }
  .modern-ui .login-panel-logo { width: 68px; height: 68px; padding: 8px; border: 1px solid #e1ecf4; border-radius: 16px; background: #f8fbfd; }
  .modern-ui .login-panel h1 { color: #213c50; letter-spacing: -.04em; }
  .modern-ui .widget-toggle { width: 76px; height: 42px; border-radius: 12px; background: #0b69a3; font-size: 13px; font-weight: 600; box-shadow: 0 4px 16px #0b69a324; }
  .modern-ui .widget-toggle:hover { background: #075788; transform: none; }
  .modern-ui .widget-toggle > span[aria-hidden] { font-size: 0; }
  .modern-ui .widget-toggle > span[aria-hidden]::after { content: 'Tareas'; font-size: 12px; }

  @media (max-width: 1100px) {
    .clinical-workspace .patient-card .grid-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .modern-ui .app-topbar { padding: 12px 20px; }
  }

  @media (min-width: 1001px) and (max-width: 1199px) {
    .clinical-workspace .patient-card .grid-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .clinical-workspace .topbar-history { min-width: 300px; width: 300px; max-width: 300px; }
  }

  @media (min-width: 1200px) {
    .clinical-workspace .patient-card .grid-4 {
      grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, .65fr) minmax(0, 1.6fr) minmax(0, 1.15fr);
    }
  }

  @media (max-width: 1000px) {
    .clinical-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
    .clinical-workspace .document-actions { position: static; max-height: none; overflow: visible; scrollbar-gutter: auto; }
    .clinical-workspace .document-actions .actions-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .clinical-workspace .document-actions .btn { text-align: center; }
    .clinical-workspace .document-actions #btnLimpiarPaciente { margin: 0; }
  }

  @media (max-width: 760px) {
    .modern-ui .container { padding: 0 16px 24px; margin-top: 22px; }
    .modern-ui .card { padding: 20px; border-radius: 15px; }
    .workspace-intro { align-items: flex-start; margin-bottom: 14px; padding: 10px 14px; }
    .workspace-format { display: none; }
    .clinical-workspace .document-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .clinical-workspace .patient-card .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .clinical-workspace .patient-card .field:first-child { grid-column: 1 / -1; }
    .clinical-workspace .actions-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .clinical-workspace .actions-row .btn { width: 100%; min-width: 0; margin: 0; }
    .clinical-workspace #btnPDF { grid-column: 1 / -1; grid-row: 1; }
    .clinical-workspace .preview-wrapper { padding: 14px; border-radius: 14px; }
    .modern-ui .app-topbar { padding: 12px 16px; }
    .modern-ui .topnav .btn { min-height: 36px; padding: 7px 9px; }
    .modern-ui .topbar-history { min-width: 0; max-width: 100%; }
    .modern-ui .topbar-history input { width: 100%; min-width: 0; }
  }

  @media (max-width: 440px) {
    .clinical-workspace .document-choices { grid-template-columns: 1fr; }
    .clinical-workspace .document-choices .chip { padding: 10px; }
    .modern-ui .card { padding: 18px; }
    .modern-ui .brand-logo { max-height: 34px; }
    .modern-ui .topnav .private-top-navigation { gap: 3px; }
    .modern-ui .topnav .private-top-menu summary { font-size: 11px; padding: 8px; }
  }

  @media (prefers-reduced-motion: reduce) {
    .modern-ui *, .modern-ui *::before, .modern-ui *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: .01ms !important; }
  }
}

@media print {
  .workspace-intro,
  .pdf-layout-settings,
  #documentPreviewDetail { display: none !important; }
}
