@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&display=swap');

:root {
    --app-bg: #f4f6f8;
    --app-nav: #343f44;
    --app-accent: #15798d;
    --app-soft: #acbec4;
    --app-text: #293238;
    --app-muted: #778087;
}

html, body { min-height: 100%; }
body { font-family: Montserrat, Arial, sans-serif; background: var(--app-bg); color: var(--app-text); }
.app-nav { background: var(--app-nav); box-shadow: 0 2px 14px rgba(0,0,0,.13); }
.app-main { max-width: 1480px; }
.navbar-brand { letter-spacing: -.02em; }
.nav-user { color: rgba(255,255,255,.92); line-height: 1.15; }
.nav-user-name { font-size: .88rem; font-weight: 600; }
.nav-user-role { color: rgba(255,255,255,.62); font-size: .7rem; margin-top: 3px; }

.card-soft { border: 0; border-radius: 18px; box-shadow: 0 8px 28px rgba(0,0,0,.08); }
.form-control, .form-select { min-height: 48px; }
.btn-brand { background: var(--app-soft); border-color: var(--app-soft); color: #20282c; }
.btn-brand:hover { background: #9cafb6; border-color: #9cafb6; color: #20282c; }

.scan-input { height: 64px; font-size: 1.25rem; border: 2px solid var(--app-soft); }
.scan-input:focus { border-color: var(--app-accent); box-shadow: 0 0 0 .25rem rgba(21,121,141,.13); }
.scan-icon { font-size: 2rem; color: var(--app-accent); }
.info-label { font-size: .78rem; color: var(--app-muted); text-transform: uppercase; }
.info-value { font-weight: 600; }
.camera-box video { width: 100%; border-radius: 14px; background: #111; max-height: 55vh; }

/* Dashboard */
.dashboard-hero {
    background: linear-gradient(135deg, #ffffff 0%, #eef3f4 100%);
    border: 1px solid rgba(52,63,68,.06);
    border-radius: 24px;
    padding: clamp(24px, 4vw, 42px);
    box-shadow: 0 10px 32px rgba(0,0,0,.07);
}
.dashboard-eyebrow { color: var(--app-accent); font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 8px; }
.dashboard-title { font-size: clamp(1.7rem, 3vw, 2.6rem); font-weight: 600; letter-spacing: -.035em; }
.dashboard-subtitle { color: #667178; max-width: 780px; }
.user-summary { background: #fff; border-radius: 18px; padding: 12px 16px; box-shadow: 0 5px 18px rgba(0,0,0,.06); min-width: 220px; }
.user-avatar { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; margin-right: 12px; border-radius: 14px; background: #e6eef0; color: var(--app-accent); font-size: 1.3rem; }
.module-card { display: flex; gap: 18px; padding: 24px; border: 1px solid rgba(52,63,68,.08); border-radius: 20px; background: #fff; color: inherit; text-decoration: none; box-shadow: 0 7px 24px rgba(0,0,0,.06); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.module-card:hover { color: inherit; transform: translateY(-3px); box-shadow: 0 12px 30px rgba(0,0,0,.10); border-color: rgba(21,121,141,.24); }
.module-card-primary { background: linear-gradient(145deg, #ffffff 0%, #f2f7f8 100%); }
.module-icon { width: 58px; height: 58px; flex: 0 0 58px; display: grid; place-items: center; border-radius: 17px; background: #e5eef0; color: var(--app-accent); font-size: 1.65rem; }
.module-content h2 { font-size: 1.05rem; font-weight: 650; margin: 2px 0 8px; }
.module-content p { color: #6d777d; font-size: .88rem; line-height: 1.55; margin-bottom: 14px; }
.module-action { color: var(--app-accent); font-size: .83rem; font-weight: 600; }
.dashboard-panel { padding: 24px; }
.panel-kicker { color: var(--app-accent); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.panel-title { font-size: 1.15rem; font-weight: 600; }
.panel-icon { color: #9aabb1; font-size: 1.65rem; }
.workflow-list { display: grid; gap: 15px; }
.workflow-item { display: flex; align-items: flex-start; gap: 13px; color: #667178; font-size: .86rem; }
.workflow-item strong { color: var(--app-text); display: block; margin-bottom: 2px; }
.workflow-number { width: 30px; height: 30px; flex: 0 0 30px; display: grid; place-items: center; border-radius: 50%; background: #e6eef0; color: var(--app-accent); font-size: .78rem; font-weight: 700; }
.api-status-box { display: flex; align-items: center; gap: 13px; padding: 18px; border-radius: 16px; background: #f7f9fa; }
.status-dot { width: 13px; height: 13px; flex: 0 0 13px; border-radius: 50%; box-shadow: 0 0 0 5px rgba(0,0,0,.04); }
.status-checking { background: #d1a13a; }
.status-online { background: #4d9c64; }
.status-offline { background: #c85a5a; }

/* Login shared fallback styles */
.login-page { min-height: 100vh; background: #cdcccc; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(760px,96vw); background: #f8f7f7; border-radius: 30px; padding: 34px 54px; }
.login-brand { text-align: center; margin-bottom: 20px; }
.login-brand img { width: 190px; }
.login-title { text-align: center; font-size: 2rem; }


/* Identidad Ediciones Legales dentro del sistema */
.brand-logo-shell {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #fff;
    display: grid;
    place-items: center;
    padding: 3px;
    overflow: hidden;
    flex: 0 0 44px;
}
.brand-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.brand-title-wrap { display: flex; flex-direction: column; line-height: 1.05; }
.brand-title { font-size: 1rem; font-weight: 700; }
.brand-subtitle { font-size: .62rem; font-weight: 500; color: rgba(255,255,255,.62); margin-top: 4px; }
.home-logo-wrap {
    width: 96px;
    height: 96px;
    flex: 0 0 96px;
    border-radius: 22px;
    background: #fff;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(0,0,0,.06);
    padding: 8px;
}
.home-logo { width: 100%; height: 100%; object-fit: contain; }
.workflow-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.admin-page-title { display: flex; align-items: center; gap: 14px; }
.admin-page-logo { width: 54px; height: 54px; object-fit: contain; background: #fff; border-radius: 12px; padding: 4px; box-shadow: 0 4px 14px rgba(0,0,0,.06); }

@media (max-width: 991.98px) {
    .workflow-grid { grid-template-columns: 1fr; }
    .nav-user { border-top: 1px solid rgba(255,255,255,.08); margin-top: 8px; padding-top: 10px !important; }
}

@media (max-width: 576px) {
    .brand-logo-shell { width: 38px; height: 38px; flex-basis: 38px; }
    .brand-subtitle { display: none; }
    .brand-title { font-size: .92rem; }
    .login-card { padding: 28px 20px; border-radius: 22px; }
    .login-title { font-size: 1.5rem; }
    .scan-input { height: 58px; font-size: 1.05rem; }
    .mobile-sticky { position: sticky; bottom: 8px; z-index: 5; }
    .dashboard-hero { border-radius: 18px; }
    .module-card { padding: 20px; gap: 14px; }
    .module-icon { width: 50px; height: 50px; flex-basis: 50px; font-size: 1.4rem; }
    .dashboard-panel { padding: 20px; }
}


/* ============================================================
   SCANNER MOVIL
   ============================================================ */

.scanner-modal-content {
    overflow: hidden;
}

.scanner-reader {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 18px;
    background: #111;
    min-height: 300px;
}

.scanner-reader video,
.scanner-reader canvas {
    max-width: 100% !important;
    border-radius: 18px;
}

.scanner-reader #reader__scan_region {
    background: #111 !important;
}

.scanner-reader #reader__dashboard {
    display: none !important;
}

.scanner-guide {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(52, 63, 68, .07);
    color: #536169;
}

@media (max-width: 575.98px) {
    .camera-box {
        padding: 16px;
    }

    .scanner-reader {
        min-height: 52vh;
        border-radius: 14px;
    }

    .scanner-reader video {
        min-height: 52vh;
        object-fit: cover;
    }

    #mCam .modal-header {
        padding-top: max(16px, env(safe-area-inset-top));
    }

    #mCam .modal-body {
        padding-bottom: max(18px, env(safe-area-inset-bottom));
    }
}

/* Firma manuscrita de recepción */
/* Firma manuscrita de recepción */
.signature-card {
    border: 1px solid rgba(52, 63, 68, .16);
    border-radius: 16px;
    padding: 16px;
    background: #f8fafb;
}
.signature-shell {
    position: relative;
    width: 100%;
    height: 220px;
    overflow: hidden;
    border: 2px solid var(--app-accent);
    border-radius: 14px;
    background: #fff;
    box-shadow: inset 0 0 0 1px rgba(21, 121, 141, .08);
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}
.signature-canvas {
    position: relative;
    z-index: 2;
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none !important;
    -ms-touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}
.signature-placeholder {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: #667178;
    text-align: center;
    pointer-events: none;
}
.signature-placeholder strong {
    color: var(--app-accent);
    font-size: 1rem;
}
.signature-placeholder span {
    font-size: .8rem;
}
.signature-placeholder-icon {
    color: var(--app-accent);
    font-size: 2rem;
    margin-bottom: 2px;
}
.signature-line {
    position: absolute;
    z-index: 1;
    left: 10%;
    right: 10%;
    bottom: 34px;
    border-bottom: 1px solid rgba(52, 63, 68, .22);
    pointer-events: none;
}
.signature-status {
    color: #667178;
    font-size: .82rem;
    font-weight: 600;
}
.signature-signed {
    border-color: #4d9c64;
    box-shadow: inset 0 0 0 1px rgba(77, 156, 100, .1);
}
.signature-signed + .signature-status {
    color: #3e8152;
}
.signature-confirmation {
    padding: 12px 12px 12px 2.25rem;
    border-radius: 12px;
    background: rgba(21, 121, 141, .06);
}
.signature-shell.signature-disabled {
    opacity: .55;
    border-color: #9aa4aa;
    background: #f1f3f4;
}
.signature-shell.signature-disabled .signature-canvas {
    cursor: not-allowed;
}

@media (max-width: 575.98px) {
    .signature-card { padding: 14px; }
    .signature-shell { height: 190px; }
    .signature-placeholder-icon { font-size: 1.7rem; }
    .signature-placeholder strong { font-size: .95rem; }
    .signature-placeholder span { font-size: .76rem; }
    .signature-line { bottom: 28px; }
}


/* PWA / instalación móvil */
.pwa-install-icon { width: 66px; height: 66px; flex: 0 0 66px; object-fit: contain; border-radius: 16px; background: #fff; padding: 4px; box-shadow: 0 5px 16px rgba(0,0,0,.08); }
.pwa-platform-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.pwa-platform-card { display: flex; align-items: flex-start; gap: 12px; padding: 15px 16px; border-radius: 14px; background: #f7f9fa; border: 1px solid rgba(52,63,68,.07); }
.pwa-platform-card > i { font-size: 1.35rem; color: var(--app-accent); margin-top: 1px; }
.pwa-platform-card strong { display: block; margin-bottom: 3px; font-size: .9rem; }
.pwa-platform-card span { display: block; color: var(--app-muted); font-size: .8rem; line-height: 1.45; }
.pwa-help { display: grid; gap: 12px; margin-top: 8px; }
.pwa-help-step { display: flex; gap: 11px; align-items: flex-start; }
.pwa-help-step > span { width: 28px; height: 28px; flex: 0 0 28px; display: grid; place-items: center; border-radius: 50%; background: #e6eef0; color: var(--app-accent); font-size: .78rem; font-weight: 700; }

@media (max-width: 767.98px) {
    .pwa-platform-grid { grid-template-columns: 1fr; }
    .pwa-install-panel .btn { width: 100%; }
}
